[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

kernel patch to fix sysvinit problem



Kernel 1.3.59 (I haven't tested any others) doesn't allow an open for
write of a named pipe or Unix-domain socket on a read-only filesystem.
This breaks the IPC used by sysvinit if the root is mounted read-only.
I submitted this patch to linux-kernel.

	Bruce

--- linux/fs/namei.c.old	Sat Feb  3 11:15:41 1996
+++ linux/fs/namei.c	Sat Feb  3 11:23:08 1996
@@ -389,21 +389,31 @@
 	if (error)
 		return error;
 	if (S_ISDIR(inode->i_mode) && (flag & 2)) {
 		iput(inode);
 		return -EISDIR;
 	}
 	if ((error = permission(inode,ACC_MODE(flag))) != 0) {
 		iput(inode);
 		return error;
 	}
-	if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
+	if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
+		/*
+		 * 2-Feb-1995 Bruce Perens <Bruce@Pixar.com>
+		 * Allow opens of Unix domain sockets and FIFOs for write on
+		 * read-only filesystems. Their data does not live on the disk.
+		 *
+		 * If there was something like IS_NODEV(inode) for
+		 * pipes and/or sockets I'd check it here.
+		 */
+	}
+	else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) {
 		if (IS_NODEV(inode)) {
 			iput(inode);
 			return -EACCES;
 		}
 		flag &= ~O_TRUNC;
 	} else {
 		if (IS_RDONLY(inode) && (flag & 2)) {
 			iput(inode);
 			return -EROFS;
 		}
--
Bruce Perens <Bruce@Pixar.com> Pixar Animation Studios
"At least Pixar's second film doesn't have to be backward-compatible with
the first". - Steve Jobs


Reply to: