[Patch:] for Kernel 2.2.7: bugfixes for ISO-FS, Atari partition

Wolfram Kleff (wkleff@bigfoot.com)
Tue, 11 May 1999 19:08:43 +0200 (CEST)


This message is in MIME format
--_=XFMail.1.3.p0.Linux:990511190843:456=_
Content-Type: text/plain; charset=iso-8859-1

This patch for Linux 2.2.7 contains some bug fixes:

- Atari partition format is now available for all architectures (endian
problems)
- Atari partition format is now verified
- privacy fixes for the ISO fs: like the vfat fs, the user who mounted the CD
owns all files, umask is supported (different behavior for superuser)
- fix for mount isofs option "mode": the permission mode should be octal not
decimal
- ISO fs support for /proc/mounts
- The uid of the user who mounted the fs is now visible in /proc/mounts (last
number).
This is necessary for many usages, most important for sysadmins who must
detect
which user mounted e.g. a CD or a FD - no more complains about users who
"forgot" their disks.
- misc minor fixes

I hope you like them,
Wolfram Kleff

--_=XFMail.1.3.p0.Linux:990511190843:456=_
Content-Disposition: attachment; filename="patch"
Content-Transfer-Encoding: quoted-printable
Content-Description: Patch for Kernel 2.2.7
Content-Type: text/plain;
charset=iso-8859-1; name=patch; SizeOnDisk=10442

diff -Nru linux-2.2.7/drivers/block/genhd.c linux/drivers/block/genhd.c
--- linux-2.2.7/drivers/block/genhd.c Tue May 11 17:57:26 1999
+++ linux/drivers/block/genhd.c Mon May 3 17:32:54 1999
@@ -223,7 +223,7 @@
*/
bh->b_state =3D 0;
=20
- if ((*(unsigned short *) (bh->b_data+510)) !=3D cpu_to_le16(MSDOS_LABEL_=
MAGIC))
+ if ((*(__u16 *) (bh->b_data+510)) !=3D cpu_to_le16(MSDOS_LABEL_MAGIC))
goto done;
=20
p =3D (struct partition *) (0x1BE + bh->b_data);
@@ -1081,7 +1081,7 @@
#endif /* CONFIG_MAC_PARTITION */
=20
#ifdef CONFIG_ATARI_PARTITION
-#include <asm/atari_rootsec.h>
+#include <linux/atari_rootsec.h>
=20
/* ++guenther: this should be settable by the user ("make config")?.
*/
@@ -1095,16 +1095,27 @@
struct rootsector *rs;
struct partition_info *pi;
ulong extensect;
+ unsigned int psum;
+ int i;
#ifdef ICD_PARTS
int part_fmt =3D 0; /* 0:unknown, 1:AHDI, 2:ICD/Supra */
#endif
=20
bh =3D bread (dev, 0, get_ptable_blocksize(dev));
- if (!bh)
- {
- printk (" unable to read block 0\n");
+ if (!bh) {
+ printk (" unable to read block 0 (partition table)\n");
return -1;
- }
+ }
+
+ /* Verify this is an Atari rootsector: */
+ psum=3D0;
+ for (i=3D0;i<256;i++) {
+ psum+=3Dntohs(((__u16 *) (bh->b_data))[i]);
+ }
+ if ((psum & 0xFFFF) !=3D 0x1234) {
+ brelse(bh);
+ return 0;
+ }
=20
rs =3D (struct rootsector *) bh->b_data;
pi =3D &rs->part[0];
@@ -1125,7 +1136,7 @@
part_fmt =3D 1;
#endif
printk(" XGM<");
- partsect =3D extensect =3D pi->st;
+ partsect =3D extensect =3D ntohl(pi->st);
while (1)
{
xbh =3D bread (dev, partsect / 2, get_ptable_blocksize(dev));
@@ -1146,8 +1157,8 @@
break;
}
=20
- add_partition(hd, minor, partsect + xrs->part[0].st,
- xrs->part[0].siz);
+ add_partition(hd, minor, partsect + ntohl(xrs->part[0].st),
+ ntohl(xrs->part[0].siz));
=20
if (!(xrs->part[1].flg & 1)) {
/* end of linked partition list */
@@ -1160,7 +1171,7 @@
break;
}
=20
- partsect =3D xrs->part[1].st + extensect;
+ partsect =3D ntohl(xrs->part[1].st) + extensect;
brelse (xbh);
minor++;
if (minor >=3D m_lim) {
@@ -1173,7 +1184,7 @@
else
{
/* we don't care about other id's */
- add_partition (hd, minor, pi->st, pi->siz);
+ add_partition (hd, minor, ntohl(pi->st), ntohl(pi->siz));
}
}
}
@@ -1200,7 +1211,7 @@
memcmp (pi->id, "RAW", 3) =3D=3D 0) )
{
part_fmt =3D 2;
- add_partition (hd, minor, pi->st, pi->siz);
+ add_partition (hd, minor, ntohl(pi->st), ntohl(pi->siz));
}
}
printk(" >");
@@ -1222,7 +1233,7 @@
char buf[8];
=20
if (first_time)
- printk("Partition check:\n");
+ printk(KERN_INFO "Partition check:\n");
first_time =3D 0;
first_sector =3D hd->part[MINOR(dev)].start_sect;
=20
@@ -1235,7 +1246,7 @@
return;
}
=20
- printk(" %s:", disk_name(hd, MINOR(dev), buf));
+ printk(KERN_INFO " %s:", disk_name(hd, MINOR(dev), buf));
#ifdef CONFIG_MSDOS_PARTITION
if (msdos_partition(hd, dev, first_sector))
return;
diff -Nru linux-2.2.7/fs/Config.in linux/fs/Config.in
--- linux-2.2.7/fs/Config.in Tue May 11 17:56:08 1999
+++ linux/fs/Config.in Sun May 2 15:58:57 1999
@@ -110,6 +110,7 @@
if [ "$CONFIG_EXPERIMENTAL" =3D "y" ]; then
bool 'Unixware slices support (EXPERIMENTAL)' CONFIG_UNIXWARE_DISKLABEL
fi
+bool 'Atari partition map support' CONFIG_ATARI_PARTITION
endmenu
=20
if [ "$CONFIG_AFFS_FS" !=3D "n" ]; then
diff -Nru linux-2.2.7/fs/isofs/inode.c linux/fs/isofs/inode.c
--- linux-2.2.7/fs/isofs/inode.c Tue Dec 29 20:40:35 1998
+++ linux/fs/isofs/inode.c Tue May 11 16:38:16 1999
@@ -122,6 +122,7 @@
unsigned char check;
unsigned int blocksize;
mode_t mode;
+ mode_t umask;
gid_t gid;
uid_t uid;
char *iocharset;
@@ -286,12 +287,18 @@
popt->unhide =3D 'n';
popt->check =3D 'u'; /* unset */
popt->blocksize =3D 1024;
- popt->mode =3D S_IRUGO | S_IXUGO; /* r-x for all. The disc could
+ if (current->uid !=3D 0) {
+ popt->mode =3D (S_IRUGO | S_IXUGO) & ~(current->fs->umask);
+ popt->umask =3D current->fs->umask;
+ } else {
+ popt->mode =3D S_IRUGO | S_IXUGO; /* r-x for all. The disc could
be shared with DOS machines so
virtually anything could be
a valid executable. */
- popt->gid =3D 0;
- popt->uid =3D 0;
+ popt->umask =3D 0;
+ }
+ popt->uid =3D current->uid;
+ popt->gid =3D current->gid;
popt->iocharset =3D NULL;
popt->utf8 =3D 0;
if (!options) return 1;
@@ -355,9 +362,28 @@
else if (!strcmp(value,"auto")) ;
else return 0;
}
+ else if ((!strcmp(this_char,"umask")
+ || !strcmp(this_char,"mode")) && value) {
+ char * vpnt =3D value;
+ unsigned int ivalue;
+ ivalue =3D 0;
+ while (*vpnt) {
+ if (*vpnt < '0' || *vpnt > '7') break;
+ ivalue =3D ivalue * 8 + (*vpnt - '0');
+ vpnt++;
+ }
+ if (*vpnt) return 0;
+ if (this_char[0]=3D=3D'u') {
+ if (ivalue > 07777) return 0;
+ popt->umask =3D ivalue;
+ popt->mode &=3D ~(popt->umask);
+ } else if (this_char[0]=3D=3D'm') {
+ if (ivalue > 0777) return 0;
+ popt->mode =3D ivalue & ~(popt->umask);
+ }
+ }
else if (value &&
(!strcmp(this_char,"block") ||
- !strcmp(this_char,"mode") ||
!strcmp(this_char,"uid") ||
!strcmp(this_char,"gid"))) {
char * vpnt =3D value;
@@ -376,9 +402,6 @@
case 'g':
popt->gid =3D ivalue;
break;
- case 'm':
- popt->mode =3D ivalue;
- break;
}
}
else return 1;
@@ -753,6 +776,7 @@
s->u.isofs_sb.s_unhide =3D opt.unhide;
s->u.isofs_sb.s_uid =3D opt.uid;
s->u.isofs_sb.s_gid =3D opt.gid;
+ s->u.isofs_sb.s_umask =3D opt.umask;
s->u.isofs_sb.s_utf8 =3D opt.utf8;
/*
* It would be incredibly stupid to allow people to mark every file on th=
e disk
@@ -1079,7 +1103,7 @@
raw_inode =3D ((struct iso_directory_record *) pnt);
=20
if (raw_inode->flags[-high_sierra] & 2) {
- inode->i_mode =3D S_IRUGO | S_IXUGO | S_IFDIR;
+ inode->i_mode =3D (S_IRUGO | S_IXUGO | S_IFDIR) & ~(inode->i_sb->u.isofs=
_sb.s_umask);
inode->i_nlink =3D 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
@@ -1097,7 +1121,7 @@
if(raw_inode->name[i]=3D=3D'.' || raw_inode->name[i]=3D=3D';')
break;
if(i =3D=3D raw_inode->name_len[0] || raw_inode->name[i] =3D=3D ';')
- inode->i_mode |=3D S_IXUGO; /* execute permission */
+ inode->i_mode |=3D S_IXUGO & ~(inode->i_sb->u.isofs_sb.s_umask); /* exe=
cute permission */
}
inode->i_uid =3D inode->i_sb->u.isofs_sb.s_uid;
inode->i_gid =3D inode->i_sb->u.isofs_sb.s_gid;
diff -Nru linux-2.2.7/fs/isofs/rock.c linux/fs/isofs/rock.c
--- linux-2.2.7/fs/isofs/rock.c Sat Sep 26 01:27:13 1998
+++ linux/fs/isofs/rock.c Tue May 11 16:40:00 1999
@@ -270,7 +270,7 @@
printk("\n");
break;
case SIG('P','X'):
- inode->i_mode =3D isonum_733(rr->u.PX.mode);
+ inode->i_mode =3D isonum_733(rr->u.PX.mode) & ~(inode->i_sb->u.isofs_sb.=
s_umask);
inode->i_nlink =3D isonum_733(rr->u.PX.n_links);
inode->i_uid =3D isonum_733(rr->u.PX.uid);
inode->i_gid =3D isonum_733(rr->u.PX.gid);
@@ -363,7 +363,7 @@
reloc =3D iget(inode->i_sb, inode->u.isofs_i.i_first_extent);
if (!reloc)
goto out;
- inode->i_mode =3D reloc->i_mode;
+ inode->i_mode =3D reloc->i_mode & ~(inode->i_sb->u.isofs_sb.s_umask);
inode->i_nlink =3D reloc->i_nlink;
inode->i_uid =3D reloc->i_uid;
inode->i_gid =3D reloc->i_gid;
diff -Nru linux-2.2.7/fs/super.c linux/fs/super.c
--- linux-2.2.7/fs/super.c Tue May 11 17:57:28 1999
+++ linux/fs/super.c Tue May 11 16:58:58 1999
@@ -32,6 +32,8 @@
#include <linux/nfs_fs_sb.h>
#include <linux/nfs_mount.h>
=20
+#include <linux/iso_fs_sb.h>
+
#ifdef CONFIG_KMOD
#include <linux/kmod.h>
#endif
@@ -103,6 +105,7 @@
lptr->mnt_sb =3D sb;
lptr->mnt_dev =3D sb->s_dev;
lptr->mnt_flags =3D sb->s_flags;
+ lptr->uid =3D current->uid;
=20
sema_init(&lptr->mnt_dquot.semaphore, 1);
lptr->mnt_dquot.flags =3D 0;
@@ -313,6 +316,7 @@
struct proc_fs_info *fs_infop;
struct proc_nfs_info *nfs_infop;
struct nfs_server *nfss;
+ struct isofs_sb_info *iso9660;
int len =3D 0;
=20
while ( tmp && len < PAGE_SIZE - 160)
@@ -371,7 +375,32 @@
len +=3D sprintf(buf+len, ",addr=3D%s",
nfss->hostname);
}
- len +=3D sprintf( buf + len, " 0 0\n" );
+ if (!strcmp("iso9660", tmp->mnt_sb->s_type->name)) {
+ iso9660 =3D &tmp->mnt_sb->u.isofs_sb;
+
+ if (! iso9660->s_rock) {
+ len +=3D sprintf(buf + len, ",norock");
+ }
+ if (iso9660->s_unhide =3D=3D 'y') {
+ len +=3D sprintf(buf + len, ",unhide");
+ }
+ if (iso9660->s_cruft =3D=3D 'y') {
+ len +=3D sprintf(buf + len, ",cruft");
+ }
+ if (iso9660->s_umask !=3D 0) {
+ len +=3D sprintf(buf + len, ",umask=3D%o", iso9660->s_umask);
+ }
+ if (iso9660->s_mode !=3D 0) {
+ len +=3D sprintf(buf + len, ",mode=3D%o", iso9660->s_mode);
+ }
+ if (iso9660->s_uid !=3D 0) {
+ len +=3D sprintf(buf + len, ",uid=3D%u", iso9660->s_uid);
+ }
+ if (iso9660->s_gid !=3D 0) {
+ len +=3D sprintf(buf + len, ",gid=3D%u", iso9660->s_gid);
+ }
+ }
+ len +=3D sprintf( buf + len, " 0 0 %u\n", tmp->uid);
tmp =3D tmp->mnt_next;
}
=20
@@ -1195,7 +1224,7 @@
sb->s_flags =3D root_mountflags;
current->fs->root =3D dget(sb->s_root);
current->fs->pwd =3D dget(sb->s_root);
- printk ("VFS: Mounted root (%s filesystem)%s.\n",
+ printk(KERN_INFO "VFS: Mounted root (%s filesystem)%s.\n",
fs_type->name,
(sb->s_flags & MS_RDONLY) ? " readonly" : "");
vfsmnt =3D add_vfsmnt(sb, "/dev/root", "/");
diff -Nru linux-2.2.7/include/linux/iso_fs_sb.h linux/include/linux/iso_fs_=
sb.h
--- linux-2.2.7/include/linux/iso_fs_sb.h Wed Aug 26 18:54:41 1998
+++ linux/include/linux/iso_fs_sb.h Tue May 11 16:52:24 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 */
diff -Nru linux-2.2.7/include/linux/mount.h linux/include/linux/mount.h
--- linux-2.2.7/include/linux/mount.h Sun Aug 9 21:25:12 1998
+++ linux/include/linux/mount.h Tue May 11 16:54:51 1999
@@ -33,6 +33,7 @@
struct super_block *mnt_sb; /* pointer to superblock */
struct quota_mount_options mnt_dquot; /* Diskquota specific mount option=
s */
struct vfsmount *mnt_next; /* pointer to next in linkedlist */
+ uid_t uid; /* uid of the user who mounted the fs */
};
=20
struct vfsmount *lookup_vfsmnt(kdev_t dev);

--_=XFMail.1.3.p0.Linux:990511190843:456=_--
End of MIME message

-
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/