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

Re: Fwd: (forw) PR ports/31629 (People with access to non-FreeBSD Unix needed to help)



Hi

Here are the results for Linux 2.2.19 on my Potato 2.2r4 box with
an ext2 file system.

General note:  On this system, man 2 chmod does not specify
either way the effect of using an invalid mode, so I think this
is undefined behavior, although it has been explicitly
implemented for some reason.  Here are the relevant lines from
the actual Linux 2.2.19 kernel source file fs/open.c:

    if (mode == (mode_t) -1)
        mode = inode->i_mode;
    newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO);
    newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
                                        

[Edited to remove control chars (^H etc.)]
Script started on Sat Dec  1 00:36:56 2001
$ cat foo.c
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>

int
main(int ac, char **av)
{
        if (ac == 3) {
                char *fn = av[1];
                char *md = av[2];
                int mode = 0xffff;
                sscanf(md, "%x", &mode);
                if (!chmod(fn, mode)) {
                        printf("chmod ok\n");
                } else {
                        printf("chmod barfed; error = %s\n",
 strerror(errno)); }
        }
        return 0;
}

$ chmod 664 foo.c
$ ls -l foo.c
-rw-rw-r--    1 jbj      jbj           480 Dec  1 00:36 foo.c
$ gcc -o foo foo.c
$ uname -a
Linux jbj2 2.2.19 #1 Fri Oct 19 22:03:10 CEST 2001 i586 unknown
$ echo Debian 2.2r4
Debian 2.2r4
$ ./foo foo.c ffff
chmod ok
$ ls -l foo.c
-rw-rw-r--    1 jbj      jbj           480 Dec  1 00:36 foo.c
$ exit

Script done on Sat Dec  1 00:39:08 2001


On Fri, Nov 30, 2001 at 10:14:45AM +0100, Russell Coker wrote:
> This apparently concerns a KDE bug.  Can we get a list of how the various 
> Linux ports work?
> 
...

-- 
This message is hastily written, please ignore any unpleasant wordings,
do not consider it a binding commitment, even if its phrasing may
indicate so. Its contents may be deliberately or accidentally untrue.
Trademarks and other things belong to their owners, if any.

Attachment: pgpCMc7dy9CuG.pgp
Description: PGP signature


Reply to: