Skip to contentSkip to conversation

libfs: return error code on failed attr set

PATCH In review [email protected] 1 participant 1 message Sep 18, 2009 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 21/21 libfs: return error code on failed attr set

From: Wu Fengguang <[email protected]>

Currently all simple_attr.set handlers return 0 on success and negative codes on error. Fix simple_attr_write() to return these error codes.

Cc Theodore Ts'o <[email protected]>
Cc Al Viro <[email protected]>
Cc Christoph Hellwig <[email protected]>
Cc Nick Piggin <[email protected]>

---

 fs/libfs.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/libfs.c renamed from fs/libfs.c~libfs-return-error-code-on-failed-attr-set +3 -2
diff -puN fs/libfs.c~libfs-return-error-code-on-failed-attr-set fs/libfs.c
@@ -739,10 +739,11 @@ ssize_t simple_attr_write(struct file *f
 	if (copy_from_user(attr->set_buf, buf, size))
 		goto out;
 
-	ret = len; /* claim we got the whole input */
 	attr->set_buf[size] = '\0';
 	val = simple_strtol(attr->set_buf, NULL, 0);
-	attr->set(attr->data, val);
+	ret = attr->set(attr->data, val);
+	if (ret == 0)
+		ret = len; /* on success, claim we got the whole input */
 out:
 	mutex_unlock(&attr->mutex);
 	return ret;

_