Messages in this thread Patch in this message | | | Subject | Patch: ISO 9660-Filesystem | Date | Tue, 12 Nov 1996 08:41:05 +0100 (MEZ) | From | "Christian A. Lademann" <> |
| |
Hi, folks.
Appended you find a patch for the ISO9660 filesystem.
o The directories '.' and '..' always have to be visible, even when marked as hidden.
o I found a cdrom that contains filenames ending with a '.' or ';' instead of '.;1'. I corrected those filenames.
o I added new options:
- mode_hidden=n or mh=n assigns a modemask to tag hidden files. For example: mh=0002 would map the hidden-attribute to S_IWOTH.
- mode_associated=n or ma=n assigns a modemask to tag associated files. For example: ma=0020 would map the associated-attribute to S_IWGRP.
This is useful in conjunction with Samba, so the attributes can be passed to M$-clients correctly.
- map=upper maps all filenames to uppercase.
I hope my patches are useful to anyone else except me :-). They should work with the newest 2.0.x-kernels.
--Christian
---------------------------------------------------------------------- Christian A. Lademann EMail: <cal@zls.com> --------------------- speaking from, not for: ------------------------ ZLS Software GmbH Tel.: (+49) 6195 900500 D-65779 Kelkheim Fax: (+49) 6195 900600 ----------------------------------------------------------------------
--( snip )-- diff -ruN linux-2.0.24/fs/isofs/dir.c linux/fs/isofs/dir.c --- linux-2.0.24/fs/isofs/dir.c Tue Jul 23 09:26:40 1996 +++ linux/fs/isofs/dir.c Thu Nov 7 02:40:06 1996 @@ -76,16 +76,24 @@ return isofs_lookup_grandparent(inode, find_rock_ridge_relocation(de, inode)); } -static int isofs_name_translate(char * old, int len, char * new) +static int isofs_name_translate(char * old, int len, char * new, char mapping) { - int i, c; + int i, c, d = 0; for (i = 0; i < len; i++) { c = old[i]; if (!c) break; - if (c >= 'A' && c <= 'Z') - c |= 0x20; /* lower case */ + + if(mapping == 'n') { + if (c >= 'A' && c <= 'Z') + c |= 0x20; /* lower case */ + } + + if(mapping == 'u') { + if (c >= 'a' && c <= 'z') + c &= ~0x20; /* upper case */ + } /* Drop trailing '.;1' (ISO9660:1988 7.5.1 requires period) */ if (c == '.' && i == len - 3 && old[i + 1] == ';' && old[i + 2] == '1') @@ -95,10 +103,21 @@ if (c == ';' && i == len - 2 && old[i + 1] == '1') break; + /* Drop trailing ';' */ + if (c == ';' && i == len - 1) + break; + /* Convert remaining ';' to '.' */ if (c == ';') c = '.'; + /* Drop trailing '.' if it is not the first '.' */ + if (c == '.') + if(d && i == len - 1) + break; + else + d++; + new[i] = c; } return i; @@ -240,7 +259,8 @@ if (inode->i_sb->u.isofs_sb.s_unhide == 'n') { /* Do not report hidden or associated files */ high_sierra = inode->i_sb->u.isofs_sb.s_high_sierra; - if (de->flags[-high_sierra] & 5) { + if (((de->flags[-high_sierra] & 1) && !inode->i_sb->u.isofs_sb.s_mode_hidden) || + ((de->flags[-high_sierra] & 4) && !inode->i_sb->u.isofs_sb.s_mode_associated)) { filp->f_pos += de_len; continue; } @@ -263,8 +283,8 @@ continue; } - if (inode->i_sb->u.isofs_sb.s_mapping == 'n') { - len = isofs_name_translate(name, len, tmpname); + if (inode->i_sb->u.isofs_sb.s_mapping != 'o') { + len = isofs_name_translate(name, len, tmpname, inode->i_sb->u.isofs_sb.s_mapping); if (filldir(dirent, tmpname, len, filp->f_pos, inode_number) < 0) break; dcache_add(inode, tmpname, len, inode_number); diff -ruN linux-2.0.24/fs/isofs/inode.c linux/fs/isofs/inode.c --- linux-2.0.24/fs/isofs/inode.c Sat Aug 17 20:19:28 1996 +++ linux/fs/isofs/inode.c Thu Nov 7 09:41:12 1996 @@ -8,6 +8,29 @@ * */ +/* + * 1996/10/23 -- Christian Lademann <cal@zls.com> + * -- added options: + * mode_hidden=n report hidden inodes with mode |= n + * mh=n alias for mode_hidden + * mode_associated=n report associated inodes with mode |= n + * ma=n alias for mode_associated + * + * octal values n are allowed, use 0 as first digit + * + * -- fixed problems: + * directories "." and ".." now show up, even when marked as hidden + * iso9660-filenames may also contain a single ';' or '.' at the end, + * delete those when mapping is activated + */ + +/* + * 1996/11/06 -- Christian Lademann <cal@zls.com> + * -- added options: + * map=upper convert all filenames to uppercase + */ + + #include <linux/module.h> #include <linux/stat.h> @@ -72,6 +95,8 @@ mode_t mode; gid_t gid; uid_t uid; + mode_t mode_hidden; + mode_t mode_associated; }; static int parse_options(char *options, struct iso9660_options * popt) @@ -88,6 +113,8 @@ popt->mode = S_IRUGO; popt->gid = 0; popt->uid = 0; + popt->mode_hidden = 0; /* default: no special mode */ + popt->mode_associated = 0; /* default: no special mode */ if (!options) return 1; for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) { if (strncmp(this_char,"norock",6) == 0) { @@ -109,6 +136,7 @@ popt->map = *value; else if (!strcmp(value,"off")) popt->map = 'o'; else if (!strcmp(value,"normal")) popt->map = 'n'; + else if (!strcmp(value,"upper")) popt->map = 'u'; else return 0; } else if (!strcmp(this_char,"check") && value) { @@ -131,13 +159,18 @@ (!strcmp(this_char,"block") || !strcmp(this_char,"mode") || !strcmp(this_char,"uid") || - !strcmp(this_char,"gid"))) { + !strcmp(this_char,"gid") || + !strcmp(this_char,"mode_hidden") || !strcmp(this_char,"mh") || + !strcmp(this_char,"mode_associated") || !strcmp(this_char,"ma"))) { char * vpnt = value; - unsigned int ivalue; + unsigned int ivalue, ibase; ivalue = 0; + ibase = 10; + if(*vpnt == '0') /* numbers starting with '0' are octals */ + ibase = 8; while(*vpnt){ if(*vpnt < '0' || *vpnt > '9') break; - ivalue = ivalue * 10 + (*vpnt - '0'); + ivalue = ivalue * ibase + (*vpnt - '0'); vpnt++; } if (*vpnt) return 0; @@ -155,12 +188,20 @@ popt->gid = ivalue; break; case 'm': - popt->mode = ivalue; + if(!strcmp(this_char, "mode")) + popt->mode = ivalue; + else if(!strcmp(this_char,"mode_hidden") || !strcmp(this_char,"mh")) + popt->mode_hidden = ivalue; + else if(!strcmp(this_char,"mode_associated") || !strcmp(this_char,"ma")) + popt->mode_associated = ivalue; break; } } - else return 1; + else break; } + + popt->mode &= ~(popt->mode_hidden | popt->mode_associated); + return 1; } @@ -257,6 +298,9 @@ printk("blocksize = %d\n", opt.blocksize); printk("gid = %d\n", opt.gid); printk("uid = %d\n", opt.uid); + printk("mode = 0%o\n", opt.mode); + printk("mode_hidden = 0%o\n", opt.mode_hidden); + printk("mode_associated = 0%o\n", opt.mode_associated); #endif blocksize_bits = 0; @@ -428,6 +472,8 @@ * as suid, so we merely allow them to set the default permissions. */ s->u.isofs_sb.s_mode = opt.mode & 0777; + s->u.isofs_sb.s_mode_hidden = opt.mode_hidden; + s->u.isofs_sb.s_mode_associated = opt.mode_associated; s->s_blocksize = opt.blocksize; s->s_blocksize_bits = blocksize_bits; s->s_mounted = iget(s, (isonum_733(rootp->extent) + @@ -554,6 +600,13 @@ break; if(i == raw_inode->name_len[0] || raw_inode->name[i] == ';') inode->i_mode |= S_IXUGO; /* execute permission */ + } +/* set hidden and associated mode-bits */ + if (raw_inode->flags[-high_sierra] & 1 && inode->i_sb->u.isofs_sb.s_mode_hidden) { + inode->i_mode |= inode->i_sb->u.isofs_sb.s_mode_hidden; + } + if (raw_inode->flags[-high_sierra] & 4 && inode->i_sb->u.isofs_sb.s_mode_associated) { + inode->i_mode |= inode->i_sb->u.isofs_sb.s_mode_associated; } inode->i_uid = inode->i_sb->u.isofs_sb.s_uid; inode->i_gid = inode->i_sb->u.isofs_sb.s_gid; diff -ruN linux-2.0.24/fs/isofs/namei.c linux/fs/isofs/namei.c --- linux-2.0.24/fs/isofs/namei.c Sat Apr 13 11:14:45 1996 +++ linux/fs/isofs/namei.c Thu Nov 7 02:42:18 1996 @@ -157,10 +157,16 @@ if (rrflag) { if (rrflag == -1) goto out; /* Relocated deep directory */ } else { - if(dir->i_sb->u.isofs_sb.s_mapping == 'n') { + if(dir->i_sb->u.isofs_sb.s_mapping != 'o') { for (i = 0; i < dlen; i++) { c = dpnt[i]; - if (c >= 'A' && c <= 'Z') c |= 0x20; /* lower case */ + + if(dir->i_sb->u.isofs_sb.s_mapping == 'n') + if (c >= 'A' && c <= 'Z') c |= 0x20; /* lower case */ + + if(dir->i_sb->u.isofs_sb.s_mapping == 'u') + if (c >= 'A' && c <= 'Z') c &= ~0x20; /* upper case */ + if (c == ';' && i == dlen-2 && dpnt[i+1] == '1') { dlen -= 2; break; @@ -175,11 +181,15 @@ } } /* - * Skip hidden or associated files unless unhide is set + * Skip hidden or associated files unless unhide or an appropriate mode is set */ match = 0; - if( !(de->flags[-dir->i_sb->u.isofs_sb.s_high_sierra] & 5) - || dir->i_sb->u.isofs_sb.s_unhide == 'y' ) + if( !(de->flags[-dir->i_sb->u.isofs_sb.s_high_sierra] & 5) + || dir->i_sb->u.isofs_sb.s_unhide == 'y' + || ((de->flags[-dir->i_sb->u.isofs_sb.s_high_sierra] & 1) && de->flags[-dir->i_sb->u.isofs_sb.s_mode_hidden]) + || ((de->flags[-dir->i_sb->u.isofs_sb.s_high_sierra] & 4) && de->flags[-dir->i_sb->u.isofs_sb.s_mode_associated]) + || (namelen == 1 && name [0] == '.') + || (namelen == 2 && name [0] == '.' && name [1] == '.')) { match = isofs_match(namelen,name,dpnt,dlen); } diff -ruN linux-2.0.24/include/linux/iso_fs_sb.h linux/include/linux/iso_fs_sb.h --- linux-2.0.24/include/linux/iso_fs_sb.h Fri Dec 22 07:51:08 1995 +++ linux/include/linux/iso_fs_sb.h Thu Oct 31 03:48:37 1996 @@ -25,6 +25,8 @@ mode_t s_mode; gid_t s_gid; uid_t s_uid; + mode_t s_mode_hidden; + mode_t s_mode_associated; }; #endif --( snip )--
| |