The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] FUSE: interrupted open fix
Date: Sun, 24 Apr 2005 17:30:51 +0200	[thread overview]
Message-ID: <E1DPj4N-0000Nd-00@localhost> (raw)

This patch fixes incorrect behavior of open(..., O_CREAT|O_EXCL) in
case it is interrupted after the file has been created.  In this case
the system call was restarted and returned -EEXIST.  The solution is
not to allow interruption.  Thanks to David Shaw for the bug report
and testing.

Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>

diff -rup linux-2.6.12-rc2-mm3/fs/fuse/file.c linux-fuse/fs/fuse/file.c
--- linux-2.6.12-rc2-mm3/fs/fuse/file.c	2005-04-22 15:37:21.000000000 +0200
+++ linux-fuse/fs/fuse/file.c	2005-04-22 15:50:32.000000000 +0200
@@ -20,6 +20,9 @@ int fuse_open_common(struct inode *inode
 	struct fuse_open_out outarg;
 	struct fuse_file *ff;
 	int err;
+	/* Restarting the syscall is not allowed if O_CREAT and O_EXCL
+	   are both set, because creation will fail on the restart */
+	int excl = (file->f_flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL);
 
 	err = generic_file_open(inode, file);
 	if (err)
@@ -33,9 +36,12 @@ int fuse_open_common(struct inode *inode
 		 	return err;
 	}
 
-	req = fuse_get_request(fc);
+	if (excl)
+		req = fuse_get_request_nonint(fc);
+	else
+		req = fuse_get_request(fc);
 	if (!req)
-		return -ERESTARTSYS;
+		return excl ? -EINTR : -ERESTARTSYS;
 
 	err = -ENOMEM;
 	ff = kmalloc(sizeof(struct fuse_file), GFP_KERNEL);
@@ -59,7 +65,10 @@ int fuse_open_common(struct inode *inode
 	req->out.numargs = 1;
 	req->out.args[0].size = sizeof(outarg);
 	req->out.args[0].value = &outarg;
-	request_send(fc, req);
+	if (excl)
+		request_send_nonint(fc, req);
+	else
+		request_send(fc, req);
 	err = req->out.h.error;
 	if (!err && !(fc->flags & FUSE_KERNEL_CACHE))
 		invalidate_inode_pages(inode->i_mapping);

                 reply	other threads:[~2005-04-24 15:31 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=E1DPj4N-0000Nd-00@localhost \
    --to=miklos@szeredi.hu \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox