git » libjio » commit 02540f4

We always need to open the file with both read and write access: we use read because we need to get the current contents before commiting a transaction, and write because of fcntl locking.

author Alberto Bertogli
2004-06-20 02:57:45 UTC
committer Alberto Bertogli
2007-07-15 13:02:49 UTC
parent e1f12e359535512f4af05015caf0625b987de414

We always need to open the file with both read and write access: we use read because we need to get the current contents before commiting a transaction, and write because of fcntl locking.

We always need to open the file with both read and write access: we use read
because we need to get the current contents before commiting a transaction,
and write because of fcntl locking.

trans.c +6 -6

diff --git a/trans.c b/trans.c
index 1867a58..f6a2a52 100644
--- a/trans.c
+++ b/trans.c
@@ -437,12 +437,12 @@ int jopen(struct jfs *fs, const char *name, int flags, int mode, int jflags)
 	char jdir[PATH_MAX], jlockfile[PATH_MAX];
 	struct stat sinfo;
 
-	/* we always need read access, because when we commit a transaction we
-	 * read the current contents before applying */
-	if (flags & O_WRONLY) {
-		flags = flags & ~O_WRONLY;
-		flags = flags | O_RDWR;
-	}
+	/* we always need read and write access, because when we commit a
+	 * transaction we read the current contents before applying, and write
+	 * access is needed for locking with fcntl */
+	flags = flags & ~O_WRONLY;
+	flags = flags & ~O_RDONLY;
+	flags = flags | O_RDWR;
 
 	fd = open(name, flags, mode);
 	if (fd < 0)