All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH 1/2] multipathd: Avoid "socket operation on non-socket" errors
Date: Fri, 14 Oct 2016 08:34:26 -0700	[thread overview]
Message-ID: <5e2dbb22-cfa0-28e4-bea7-ac0129c6b433@sandisk.com> (raw)
In-Reply-To: <a7920385-9f76-d029-48dd-31ebcb06a212@sandisk.com>

Changing write_all() into write() is safe for files since the
POSIX standard guarantees that write() writes the entire buffer
except if the disk is full, a resource limit is encountered or
if interrupted by a signal. See also
http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html.

Fixes: commit 810082e7a8cf ("libmultipath, multipathd: Rework SIGPIPE handling")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
---
 libmultipath/alias.c | 2 +-
 libmultipath/file.c  | 2 +-
 libmultipath/wwids.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libmultipath/alias.c b/libmultipath/alias.c
index b86843a..12afef8 100644
--- a/libmultipath/alias.c
+++ b/libmultipath/alias.c
@@ -219,7 +219,7 @@ allocate_binding(int fd, char *wwid, int id, char *prefix)
 			strerror(errno));
 		return NULL;
 	}
-	if (write_all(fd, buf, strlen(buf)) != strlen(buf)){
+	if (write(fd, buf, strlen(buf)) != strlen(buf)){
 		condlog(0, "Cannot write binding to bindings file : %s",
 			strerror(errno));
 		/* clear partial write */
diff --git a/libmultipath/file.c b/libmultipath/file.c
index 74cde64..e4951c9 100644
--- a/libmultipath/file.c
+++ b/libmultipath/file.c
@@ -158,7 +158,7 @@ open_file(char *file, int *can_write, char *header)
 			goto fail;
 		/* If file is empty, write the header */
 		size_t len = strlen(header);
-		if (write_all(fd, header, len) != len) {
+		if (write(fd, header, len) != len) {
 			condlog(0,
 				"Cannot write header to file %s : %s", file,
 				strerror(errno));
diff --git a/libmultipath/wwids.c b/libmultipath/wwids.c
index babf149..bc70a27 100644
--- a/libmultipath/wwids.c
+++ b/libmultipath/wwids.c
@@ -71,7 +71,7 @@ write_out_wwid(int fd, char *wwid) {
 			strerror(errno));
 		return -1;
 	}
-	if (write_all(fd, buf, strlen(buf)) != strlen(buf)) {
+	if (write(fd, buf, strlen(buf)) != strlen(buf)) {
 		condlog(0, "cannot write wwid to wwids file : %s",
 			strerror(errno));
 		if (ftruncate(fd, offset))
@@ -110,7 +110,7 @@ replace_wwids(vector mp)
 		goto out_file;
 	}
 	len = strlen(WWIDS_FILE_HEADER);
-	if (write_all(fd, WWIDS_FILE_HEADER, len) != len) {
+	if (write(fd, WWIDS_FILE_HEADER, len) != len) {
 		condlog(0, "Can't write wwid file header : %s",
 			strerror(errno));
 		/* cleanup partially written header */
-- 
2.10.0

  reply	other threads:[~2016-10-14 15:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14 15:33 [PATCH 0/2] Two multipath-tools bug fixes Bart Van Assche
2016-10-14 15:34 ` Bart Van Assche [this message]
2016-10-14 15:35 ` [PATCH 2/2] multipathd: Avoid that a deadlock is triggered sporadically during shutdown Bart Van Assche
2016-10-20 22:28   ` Xose Vazquez Perez
2016-10-20 22:47     ` Bart Van Assche
2016-10-16  7:52 ` [PATCH 0/2] Two multipath-tools bug fixes Christophe Varoqui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5e2dbb22-cfa0-28e4-bea7-ac0129c6b433@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.