I am afraid it might be a unionfs copyup_permissions() bug.
It copies some attributes of the inode, but timestamps.
When a user chmod to the file on ro branch, unionfs will copyup the
file, and the timestamps will be updated illegally.

/dev/shm/u$ grep union /proc/mounts
unionfs /dev/shm/u unionfs 
rw,dirs=/dev/shm/rw=rw:/dev/shm/ro=ro,debug=0,delete=whiteout,copyup=preserve 0 0
/dev/shm/u$ ls -l ../r?/f_dst f_dst
-rw-r--r--  1 jro jro 2 Dec 20 14:15 ../ro/f_dst
-rw-r--r--  1 jro jro 2 Dec 20 14:15 f_dst

It shows 'f_dst' exists on ro branch only.

/dev/shm/u$ stat f_dst
  File: `f_dst'
  Size: 2               Blocks: 2          IO Block: 4096   regular file
Device: 22h/34d Inode: 4           Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/     jro)   Gid: ( 1000/     jro)
Access: 2005-12-20 14:15:40.000000000 +0900
Modify: 2005-12-20 14:15:40.000000000 +0900
Change: 2005-12-20 14:15:40.000000000 +0900
/dev/shm/u$ chmod a+w f_dst
/dev/shm/u$ stat f_dst
  File: `f_dst'
  Size: 2               Blocks: 2          IO Block: 4096   regular file
Device: 22h/34d Inode: 4           Links: 1
Access: (0666/-rw-rw-rw-)  Uid: ( 1000/     jro)   Gid: ( 1000/     jro)
Access: 2005-12-20 14:17:24.000000000 +0900
Modify: 2005-12-20 14:17:24.000000000 +0900
Change: 2005-12-20 14:17:24.000000000 +0900

It shows three timestamps are updated after chmod.
In this case, mtime must not be changed.

Here is a patch.


Junjiro Okajima


--- unionfs-20051130-1554.orig/copyup.c 2005-12-01 05:54:06.000000000 +0900
+++ unionfs-20051130-1554/copyup.c      2005-12-20 14:12:02.000000000 +0900
@@ -137,7 +137,11 @@ static int copyup_permissions(struct sup
 
        print_entry_location();
 
-       newattrs.ia_valid = ATTR_CTIME;
+       newattrs.ia_atime = old_hidden_dentry->d_inode->i_atime;
+       newattrs.ia_mtime = old_hidden_dentry->d_inode->i_mtime;
+       newattrs.ia_ctime = old_hidden_dentry->d_inode->i_ctime;
+       newattrs.ia_valid = ATTR_CTIME | ATTR_ATIME | ATTR_MTIME |
+               ATTR_ATIME_SET | ATTR_MTIME_SET;
        if (IS_SET(sb, COPYUP_FS_MOUNTER)) {
                /* f/s mounter */
                newattrs.ia_mode = stopd(sb)->copyupmode;
_______________________________________________
unionfs mailing list
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs

Reply via email to