[comp.os.minix] Crossing Mount Points

joerg@mwtech.UUCP (Joerg Werner) (08/20/90)

I am using Minix ST 1.1, but I believe the following problem exists in
MINIX 1.5 (PC and ST), too. 

Crossing from the mounting filesystem to the mounted-on filesystem
(cd ..) works only if the i-node-modes of the mounted-on and
mounted directories are identical (similar at least :-). 

Try following commands:

# mkdir /mnt			# if not already exists
# chmod 000 /mnt		# mounted-on inode-mode
# ls -dl /mnt
d---------  2     root       32 Jun 16 17:41 /mnt
# /etc/mount /dev/disk /mnt	# use your favourite device
# chmod 755 /mnt		# mounted inode-mode
# ls -dl /mnt
drwxr-xr-x  2     root       32 Jun 16 17:41 /mnt
# cd /mnt
# cd ..				# good luck

If everything works ok so far, I am wrong and you can type 'n'. But
if you can't change the directory, there is probably a bug in the FS. 
(Of course "cd /"  still works.)

I think the function forbidden(rip,access_desired,real_uid) in
fs/protect,c is responsible for that. (I refer to AST's book
[11779-11824].-)

forbidden() doesn't check, if the inode 'rip' is a mounted point. If
the inode is marked as "mounted-on" this routine should find the
mounted inode and determine if the access for this inode is allowed.

I include the changes I made.

BTW, try this with SCO XENIX :-(. But before you change the directories
you must log in as a normal user (not root). If you type

$ cd /mnt
$ ls -la

you will probably miss the ".." entry.

Joerg

------------------------------------------------------------------------
PUBLIC int forbidden(rip, access_desired, real_uid)
register struct inode *rip;
mask_bits access_desired;
int real_uid;
{
  register struct inode *old_rip = rip;
  register struct super_block *sp;
  register mask_bits bits, perm_bits, xmask;
  int r, shift, test_uid, test_gid;

  extern struct inode *get_inode();

  if (rip->i_mount == I_MOUNT)	/* The inode is mounted on. */
	for (sp = &super_block[1]; sp < &super_block[NR_SUPERS]; sp++)
		if (sp->s_imount == rip) {
			rip = get_inode(sp->s_dev, ROOT_INODE);
			break;
		} /* if */

  [ ... old code (not changed)... ]

  if (rip != old_rip) put_inode(rip);

  return r;
} /* forbidden */
-- 
Joerg Werner, email: joerg@mwtech.UUCP, voice: 49-(0)6151-37 33 66