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

MinixFS: directory creation und symlinks



There are two other places where MinixFS uses the ruid instead of the
euid, that is when it creates a directory or a symlink (although for
the latter it does not matter).  Also, the size of a symlink node is
set to the length + 1, but Linux (and probably Minix too) expects it
to be the length without the terminating null.  And neither Linux nor
Minix knows anything about drive specifiers, but MiNTlib always adds
U: to an absolute path, making it difficult to, for example, extract
the Linux root filesystem with its symlinks under MiNT.  I have fixed
this by always stripping the U: prefix on symlink creation and adding
it back in readlink.  This isn't fully backward compatible since
before an absolute link target without drive has been interpreted
relative to the current drive, but i don't thinks this is much of a
problem.  Another difference is that the link size reported by
getxattr may be off by two, but MiNT always uses PATH_MAX when reading
a link.  If this creates a problem then getxattr will have to check if
the symlink name starts with a slash and add two to the size in this
case.


--- orig/minixfs/minixfs.c	Fri May 13 05:18:04 1994
+++ minixfs/minixfs.c	Sat Oct  8 15:04:02 1994
@@ -412,8 +422,8 @@
 	/* Set up inode */
 	bzero(&ripnew,sizeof(d_inode));
 	ripnew.i_mode=I_DIRECTORY | (mode & 0777);
-	ripnew.i_uid=Getuid();
-	ripnew.i_gid=Getgid();
+	ripnew.i_uid=Geteuid();
+	ripnew.i_gid=Getegid();
 	ripnew.i_nlinks=2;
 	ripnew.i_mtime=Unixtime(Timestamp(), Datestamp());
 	ripnew.i_ctime=ripnew.i_mtime;
@@ -1364,6 +1379,10 @@
 		return EACCDN;
 	}
 
+	/* Strip U: prefix */
+	if ((to[0] == 'u' || to[0] == 'U') && to[1] == ':' && to[2] == '\\')
+	  to += 2;
+
 	if(strlen(to)>=SYMLINK_NAME_MAX)
 	{
 		DEBUG("minixfs: Symbolic link name too long");		
@@ -1381,9 +1400,9 @@
 
 	bzero(&rip,sizeof(d_inode));
 	rip.i_mode=I_SYMLINK | 0777;
-	rip.i_size=strlen(to)+1;
-	rip.i_uid=Getuid();
-	rip.i_gid=Getgid();
+	rip.i_size=strlen(to);
+	rip.i_uid=Geteuid();
+	rip.i_gid=Getegid();
 	rip.i_mtime=Unixtime(Timestamp(),Datestamp());
 	rip.i_ctime=rip.i_mtime;
 	rip.i_atime=rip.i_mtime;
@@ -1420,6 +1439,12 @@
 		return EACCDN;
 	}
 	read_zone(rip.i_zone[0],&temp,file->dev,&syscache);
+	if (temp.bdata[0] == '/' && len > 2)
+	  {
+	    *buf++ = 'u';
+	    *buf++ = ':';
+	    len -= 2;
+	  }
 	if(stob_ncpy(buf, (char *) &temp,len))
 	{
 		DEBUG("m_readlink: name too long");