From 0e5350899c9b16ed867d12856665f008357dea79 Mon Sep 17 00:00:00 2001
From: Miklos Szeredi <miklos@szeredi.hu>
Date: Mon, 13 Oct 2003 10:08:06 +0000
Subject: [PATCH] fix

---
 ChangeLog      |  4 ++++
 Filesystems    |  2 +-
 include/fuse.h | 51 +++++++++++++++++++++++++-------------------------
 kernel/dev.c   | 14 +++++++-------
 lib/fuse.c     |  2 +-
 5 files changed, 38 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4396094..78180c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-10-13  Miklos Szeredi <mszeredi@inf.bme.hu>
+
+	* Error code fixes in kernel module
+	
 2003-10-04  Miklos Szeredi <mszeredi@inf.bme.hu>
 
 	* kernel version detection fix
diff --git a/Filesystems b/Filesystems
index 3d51d3b..347e1f7 100644
--- a/Filesystems
+++ b/Filesystems
@@ -10,7 +10,7 @@ Description:
   files in a directory. 
 
 ==============================================================================
-Name: FunFS
+Name: FunFS (status: alpha)
 
 Author: Michael Grigoriev (Net Integration Technologies) <mag at
 luminal org>
diff --git a/include/fuse.h b/include/fuse.h
index 30d5f80..b54cb47 100644
--- a/include/fuse.h
+++ b/include/fuse.h
@@ -120,6 +120,31 @@ struct fuse_context {
 extern "C" {
 #endif
 
+/*
+ * Main function of FUSE.
+ *
+ * This is for the lazy.  This is all that has to be called from the
+ * main() function.
+ * 
+ * This function does the following:
+ *   - mounts the filesystem
+ *   - installs signal handlers for INT, HUP, TERM and PIPE
+ *   - registers an exit handler to unmount the filesystem on program exit
+ *   - parses command line options (-d -s and -h)
+ *   - creates a fuse handle
+ *   - registers the operations
+ *   - calls either the single-threaded or the multi-threaded event loop
+ *
+ * @param argc the argument counter passed to the main() function
+ * @param argv the argument vector passed to the main() function
+ * @param op the file system operation 
+ */
+void fuse_main(int argc, char *argv[], const struct fuse_operations *op);
+
+/* ----------------------------------------------------------- *
+ * More detailed API                                           *
+ * ----------------------------------------------------------- */
+
 /*
  * Create a FUSE mountpoint
  *
@@ -169,7 +194,6 @@ void fuse_destroy(struct fuse *f);
  */
 void fuse_loop(struct fuse *f);
 
-
 /**
  * Exit from event loop
  *
@@ -202,31 +226,6 @@ void fuse_loop_mt(struct fuse *f);
  */
 struct fuse_context *fuse_get_context(struct fuse *f);
 
-/* ----------------------------------------------------------- *
- * Miscellaneous helper fuctions                               *
- * ----------------------------------------------------------- */
-
-/*
- * Main function of FUSE.
- *
- * This is for the lazy.  This is all that has to be called from the
- * main() function.
- * 
- * This function does the following:
- *   - mounts the filesystem
- *   - installs signal handlers for INT, HUP, TERM and PIPE
- *   - registers an exit handler to unmount the filesystem on program exit
- *   - parses command line options (-d -s and -h)
- *   - creates a fuse handle
- *   - registers the operations
- *   - calls either the single-threaded or the multi-threaded event loop
- *
- * @param argc the argument counter passed to the main() function
- * @param argv the argument vector passed to the main() function
- * @param op the file system operation 
- */
-void fuse_main(int argc, char *argv[], const struct fuse_operations *op);
-
 /* ----------------------------------------------------------- *
  * Advanced API for event handling, don't worry about this...  *
  * ----------------------------------------------------------- */
diff --git a/kernel/dev.c b/kernel/dev.c
index cdc4b6c..e34bee5 100644
--- a/kernel/dev.c
+++ b/kernel/dev.c
@@ -192,7 +192,7 @@ static inline int copy_in_one(const void *src, size_t srclen, char **dstp,
 {
 	if(*dstlenp < srclen) {
 		printk("fuse_dev_read: buffer too small\n");
-		return -EIO;
+		return -EINVAL;
 	}
 			
 	if(copy_to_user(*dstp, src, srclen))
@@ -298,7 +298,7 @@ static inline int copy_out_one(struct fuse_out_arg *arg, const char **srcp,
 	if(*srclenp < dstlen) {
 		if(!allowvar) {
 			printk("fuse_dev_write: write is short\n");
-			return -EIO;
+			return -EINVAL;
 		}
 		dstlen = *srclenp;
 	}
@@ -342,7 +342,7 @@ static inline int copy_out_args(struct fuse_out *out, const char *buf,
 
 	if(nbytes != 0) {
 		printk("fuse_dev_write: write is long\n");
-		return -EIO;
+		return -EINVAL;
 	}
 
 	return 0;
@@ -353,7 +353,7 @@ static inline int copy_out_header(struct fuse_out_header *oh, const char *buf,
 {
 	if(nbytes < sizeof(struct fuse_out_header)) {
 		printk("fuse_dev_write: write is short\n");
-		return -EIO;
+		return -EINVAL;
 	}
 	
 	if(copy_from_user(oh, buf, sizeof(struct fuse_out_header)))
@@ -381,7 +381,7 @@ static int fuse_user_request(struct fuse_conn *fc, const char *buf,
 
 	if (nbytes < sizeof(struct fuse_user_header)) {
 		printk("fuse_dev_write: write is short\n");
-		return -EIO;
+		return -EINVAL;
 	}
 
 	if(copy_from_user(&uh, buf, sizeof(struct fuse_out_header)))
@@ -421,7 +421,7 @@ static ssize_t fuse_dev_write(struct file *file, const char *buf,
 
         if (oh.error <= -512 || oh.error > 0) {
                 printk("fuse_dev_write: bad error value\n");
-                return -EIO;
+                return -EINVAL;
         }
 
 	spin_lock(&fuse_lock);
@@ -560,7 +560,7 @@ int fuse_dev_init()
 	if(!fuse_req_cachep)
 		return -ENOMEM;
 
-	ret = -EIO;
+	ret = -ENOMEM;
 	proc_fs_fuse = proc_mkdir("fuse", proc_root_fs);
 	if(!proc_fs_fuse) {
 		printk("fuse: failed to create directory in /proc/fs\n");
diff --git a/lib/fuse.c b/lib/fuse.c
index efe9e97..d0537fc 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -843,7 +843,7 @@ static void do_write(struct fuse *f, struct fuse_in_header *in,
         if((size_t) res != arg->size) {
             fprintf(stderr, "short write: %u (should be %u)\n", res,
                     arg->size);
-            res = -EIO;
+            res = -EINVAL;
         }
         else 
             res = 0;
-- 
2.30.2