hurd-devel
[Top][All Lists]
Advanced

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

Re: stampede hd0*


From: Roland McGrath
Subject: Re: stampede hd0*
Date: Thu, 3 Jan 2002 20:15:35 -0500 (EST)

I figured out the chmod bug, though I don't see why it happens for chown too.

I see two problems in diskfs and ext2fs in their handling of the S_IPTRANS
bit.  But it is not entirely clear what the interface guarantees are
intended to be.  First, diskfs_S_file_chmod implicitly clears both S_ITRANS
bits from dn_stat.st_mode, which I think is wrong.  I guess the S_IATRANS
bit in dn_stat.st_mode never matters one way or the other (diskfs_S_io_stat
sets it in the result as needed), so I don't know whether it is supposed to
be set or not.  The S_IPTRANS bit in dn_stat.st_mode communicates the
translatedness state between diskfs and the filesystem back end.  It's not
clear to me whether clearing that in dn_stat.st_mode and then calling
diskfs_write_disknode is supposed to clear the translator setting on disk.

That is what the ext2fs code does, but it doesn't do all the bookkeeping
properly if that happens without diskfs_set_translator having been called
to clear it.  The ufs code doesn't examine S_IPTRANS at all.

So I think that ext2fs is incorrect to test S_IPTRANS in write_node.
However, that test can never mismatch the existing i_translator setting if
diskfs_set_translator was called.  And I think diskfs is incorrect for
clearing S_IPTRANS in dn_stat.st_mode before calling write_node.

I am surmising that the protocol is, or should be, that S_IPTRANS is never
modified in dn_stat.st_mode by diskfs, and the diskfs_set_translator
callback is the only thing that should ever change it.  If that's right,
the following patch to diskfs makes it preserve the bit during file_chmod.
With that, the ext2fs code that tests S_IPTRANS will never change anything
from how it is, and so I am inclined to remove it just for clarity.


Comments?


Index: file-chmod.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/file-chmod.c,v
retrieving revision 1.11
diff -u -b -p -r1.11 file-chmod.c
--- file-chmod.c        10 Aug 1998 17:42:35 -0000      1.11
+++ file-chmod.c        4 Jan 2002 01:13:40 -0000
@@ -1,5 +1,5 @@
 /* libdiskfs implementation of fs.defs: file_chmod
-   Copyright (C) 1992, 1993, 1994, 1996, 1997 Free Software Foundation
+   Copyright (C) 1992,93,94,96,97,2002 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -43,10 +43,11 @@ diskfs_S_file_chmod (struct protid *cred
                         err = diskfs_validate_mode_change (np, mode);
                         if (!err)
                           {
+                            mode |= (np->dn_stat.st_mode & S_ITRANS);
                             np->dn_stat.st_mode = mode;
                             np->dn_set_ctime = 1;
                             if (np->filemod_reqs)
-                              diskfs_notice_filechange(np, 
+                              diskfs_notice_filechange (np,
                                                        FILE_CHANGED_META, 
                                                        0, 0);
                           }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]