[PATCH] isofs "umask" option, kernel 2.2.2

Andreas Gerstlauer (andreas@gerstlauer.de)
Mon, 01 Mar 1999 18:41:11 -0800


This is a multipart MIME message.

--==_Exmh_-8216837250
Content-Type: text/plain; charset=us-ascii

I made a patch to add support for the "umask" option (which is
mentioned in Documentation/filesystems/isofs.txt but not
implemented) of the iso96600 file system.
In contrast to the "mode" option "umask" applies to both files
and directories, conforming with other filesystems.
In essence this renders "mode" obsolete but I didn't want to
remove it for compatibility...

In addition, I made the gid, uid and umask options to conform
with the semantics in other (non-UNIX, e.g. fat) filesystems:
* Default are the values of the current process.
* They only apply to non-UNIX CD-ROMs (i.e. w/o Rockridge).
It wasn't clear to me why one would allow to change these
values for a UNIX-like filesystem if the filesystem comes
with permissions in the first place. All other UNIX-like
filesystems don't allow them to be changed. In addition,
why is only the uid but not the gid overwritten in case of
Rockridge extensions (as it is right now, see the line with
"test_and_set_uid")?

I couldn't find a maintainer for isofs so I am posting this to
the list. BTW, I am new to the kernel hacking business so (a) is
this the right place for the patch and (b) are there any other
places where a patch should be posted?

P.S.: Please cc me on any answers since I am not subscribed to
the list.

--
Andreas Gerstlauer                          andreas@gerstlauer.de
                                http://www.gerstlauer.de/~andreas

--==_Exmh_-8216837250 Content-Type: text/plain ; name="isofs_umask-2.2.2.patch"; charset=us-ascii Content-Description: isofs_umask-2.2.2.patch Content-Disposition: attachment; filename="isofs_umask-2.2.2.patch"

--- linux-2.2.2/fs/isofs/inode.c.orig Tue Dec 29 11:40:35 1998 +++ linux/fs/isofs/inode.c Sun Feb 28 00:04:50 1999 @@ -7,6 +7,7 @@ * 1995 Mark Dobie - allow mounting of some weird VideoCDs and PhotoCDs. * 1997 Gordon Chaffee - Joliet CDs * 1998 Eric Lammerts - ISO 9660 Level 3 + * 1999 Andreas Gerstlauer - added support for "umask" option */ #include <linux/config.h> @@ -122,6 +123,7 @@ unsigned char check; unsigned int blocksize; mode_t mode; + mode_t umask; gid_t gid; uid_t uid; char *iocharset; @@ -290,8 +292,9 @@ be shared with DOS machines so virtually anything could be a valid executable. */ - popt->gid = 0; - popt->uid = 0; + popt->umask = current->fs->umask; + popt->gid = current->gid; + popt->uid = current->uid; popt->iocharset = NULL; popt->utf8 = 0; if (!options) return 1; @@ -355,6 +358,12 @@ else if (!strcmp(value,"auto")) ; else return 0; } + else if (!strcmp(this_char,"umask") && value) { + char * vpnt = value; + unsigned int ivalue = simple_strtoul(vpnt, &vpnt, 8); + if (*vpnt) return 0; + popt->umask = ivalue; + } else if (value && (!strcmp(this_char,"block") || !strcmp(this_char,"mode") || @@ -490,6 +499,8 @@ printk("blocksize = %d\n", opt.blocksize); printk("gid = %d\n", opt.gid); printk("uid = %d\n", opt.uid); + printk("mode = %d\n", opt.mode); + printk("umask = %d\n", opt.umask); printk("iocharset = %s\n", opt.iocharset); #endif @@ -754,6 +765,7 @@ s->u.isofs_sb.s_uid = opt.uid; s->u.isofs_sb.s_gid = opt.gid; s->u.isofs_sb.s_utf8 = opt.utf8; + s->u.isofs_sb.s_umask = opt.umask; /* * It would be incredibly stupid to allow people to mark every file on the disk * as suid, so we merely allow them to set the default permissions. @@ -957,7 +969,7 @@ return (b_off - offset + firstext) >> ISOFS_BUFFER_BITS(inode); } - +#if 0 static void test_and_set_uid(uid_t *p, uid_t value) { if(value) { @@ -967,6 +979,7 @@ #endif } } +#endif static int isofs_read_level3_size(struct inode * inode) { @@ -1078,8 +1091,9 @@ + (inode->i_ino & (bufsize - 1))); raw_inode = ((struct iso_directory_record *) pnt); + /* Directory? */ if (raw_inode->flags[-high_sierra] & 2) { - inode->i_mode = S_IRUGO | S_IXUGO | S_IFDIR; + inode->i_mode = ((S_IRUGO | S_IXUGO) & ~inode->i_sb->u.isofs_sb.s_umask) | S_IFDIR; inode->i_nlink = 1; /* Set to 1. We know there are 2, but the find utility tries to optimize if it is 2, and it screws up. It is @@ -1089,7 +1103,6 @@ /* Everybody gets to read the file. */ inode->i_mode = inode->i_sb->u.isofs_sb.s_mode; inode->i_nlink = 1; - inode->i_mode |= S_IFREG; /* If there are no periods in the name, * then set the execute permission bit */ @@ -1097,7 +1110,9 @@ if(raw_inode->name[i]=='.' || raw_inode->name[i]==';') break; if(i == raw_inode->name_len[0] || raw_inode->name[i] == ';') - inode->i_mode |= S_IXUGO; /* execute permission */ + if(!IS_NOEXEC(inode)) inode->i_mode |= S_IXUGO; /* execute permission */ + inode->i_mode &= ~inode->i_sb->u.isofs_sb.s_umask; + inode->i_mode |= S_IFREG; } inode->i_uid = inode->i_sb->u.isofs_sb.s_uid; inode->i_gid = inode->i_sb->u.isofs_sb.s_gid; @@ -1168,7 +1183,7 @@ if (!high_sierra) { parse_rock_ridge_inode(raw_inode, inode); /* hmm..if we want uid or gid set, override the rock ridge setting */ - test_and_set_uid(&inode->i_uid, inode->i_sb->u.isofs_sb.s_uid); + /* test_and_set_uid(&inode->i_uid, inode->i_sb->u.isofs_sb.s_uid); */ } #ifdef DEBUG --- linux-2.2.2/include/linux/iso_fs_sb.h.orig Wed Aug 26 09:54:41 1998 +++ linux/include/linux/iso_fs_sb.h Sun Feb 28 00:05:47 1999 @@ -23,6 +23,7 @@ unsigned char s_nosuid; unsigned char s_nodev; mode_t s_mode; + mode_t s_umask; gid_t s_gid; uid_t s_uid; struct nls_table *s_nls_iocharset; /* Native language support table */

--==_Exmh_-8216837250--

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/