bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems


From: Bruno Haible
Subject: Re: [PATCH] fchmodat, lchmod: port to buggy Linux filesystems
Date: Sun, 16 Feb 2020 18:24:39 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-171-generic; KDE/5.18.0; x86_64; ; )

I wrote:
> But what I observe is that the behaviour is the same on all major file
> systems on Linux.
> 
> Tested on Linux 5.3.7 (fc31), with the trivial program below, on
>   - ext4
>   - btrfs
>   - jfs
>   - reiserfs
>   - xfs

This are different when using the code which goes through the /proc
file system:

===============================================================================
#define _GNU_SOURCE 1
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
int main (int argc, char *argv[])
{
        int mode = strtol (argv[1], NULL, 8);
        char* path = argv[2];
        int ret;
        int fd = openat (AT_FDCWD, path, O_PATH | O_NOFOLLOW | O_CLOEXEC);
        if (fd < 0)
                ret = -1;
        else {
                char buf[100];
                sprintf (buf, "/proc/self/fd/%d", fd);
                ret = chmod (buf, mode);
        }
        if (ret < 0)
                perror ("lchmod");
}
===============================================================================

In this case:
- On ext4, btrfs, jfs, xfs:
    mode changed, but error "Operation not supported".
- On reiserfs:
    mode changed, success.




reply via email to

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