>>>>> On 2005-06-10 15:26 PDT, Blaisorblade  writes:

    Blaisorblade> Ok, in this case there's probably a simpler
    Blaisorblade> road: simply use a 2.4.27-1bs kernel. The
    Blaisorblade> implemented behaviour is that all created files
    Blaisorblade> will have the ID they have on the host, i.e. the
    Blaisorblade> ID of the user running UML.

Thanks for the tip!  I will be running UML under different user
IDs but I'd rather it always be the same uid inside the UML.  I
used this micropatch to get exactly the behavior I want.  It's
obviously for this particular experiment only; I still think
uid,gid mount options would be better in general.  I guess that's
only 5 or 10 more lines of code...


diff -u 
/home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/.backup/hostfs_kern.c.\~1\~
 /home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/hostfs_kern.c
--- 
/home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/.backup/hostfs_kern.c.~1~
 2005-06-10 16:58:51.000000000 -0700
+++ /home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/hostfs_kern.c     
2005-06-10 17:35:01.829485585 -0700
@@ -1,3 +1,6 @@
+#define KLUDGE_FS_UID 7777
+#define KLUDGE_FS_GID 7777
+
 /*
  * Copyright (C) 2000 - 2003 Jeff Dike ([EMAIL PROTECTED])
  * Licensed under the GPL
@@ -142,6 +145,10 @@
        ino->i_blocks = i_blocks;
        if(kdev_same(ino->i_sb->s_dev, ROOT_DEV) && (ino->i_uid == getuid()))
                ino->i_uid = 0;
+        else if (ino->i_uid == getuid()) {          /* KC KLUDGE */
+                ino->i_uid = KLUDGE_FS_UID;         /* KC KLUDGE */
+                ino->i_gid = KLUDGE_FS_GID;         /* KC KLUDGE */
+        }                                           /* KC KLUDGE */
        return(0);
 }
 
@@ -760,13 +767,17 @@
                if(kdev_same(dentry->d_inode->i_sb->s_dev, ROOT_DEV) &&
                   (attr->ia_uid == 0))
                        attr->ia_uid = getuid();
+                else if (attr->ia_uid == KLUDGE_FS_UID) { /* KC KLUDGE */
+                        attr->ia_uid = getuid();          /* KC KLUDGE */
+                        attr->ia_gid = getgid();          /* KC KLUDGE */
+                }                                         /* KC KLUDGE */
                attrs.ia_valid |= HOSTFS_ATTR_UID;
                attrs.ia_uid = attr->ia_uid;
        }
        if(attr->ia_valid & ATTR_GID){
                if(kdev_same(dentry->d_inode->i_sb->s_dev, ROOT_DEV) &&
                   (attr->ia_gid == 0))
-                       attr->ia_gid = getuid();
+                       attr->ia_gid = getgid();
                attrs.ia_valid |= HOSTFS_ATTR_GID;
                attrs.ia_gid = attr->ia_gid;
        }


-- 
Karl 2005-06-10 17:44


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

Reply via email to