[Top] [All Lists]

fsetxattr() fails on a writable descriptor?

To: xfs@xxxxxxxxxxx
Subject: fsetxattr() fails on a writable descriptor?
From: Pádraig Brady <P@xxxxxxxxxxxxxx>
Date: Tue, 8 Sep 2009 12:29:49 +0100
Cc: CoreutilsBugs <bug-coreutils@xxxxxxx>
In-reply-to: <1252318482.3852.18.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
References: <1251987642.3855.36.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> <4AA1A3E6.2020606@xxxxxxxxxxxxxx> <87k50den1e.fsf@xxxxxxxxxxxx> <1252309787.3852.8.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> <4AA4C950.3080303@xxxxxxxxxxxxxx> <1252318482.3852.18.camel@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
User-agent: Thunderbird (X11/20071008)
fsetxattr() is failing for me when the permissions are readonly
but the descriptor is writable as demonstrated by the program below.
I've tried this on ext3 and ext4 with libattr-2.4.43-3.fc11.i586
and linux-

Is this expected?


#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <attr/libattr.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
    int wfd;
    if ((wfd=open("writable", O_CREAT|O_WRONLY|O_EXCL, S_IRUSR)) == -1)
        fprintf(stderr, "open('writable') error [%m]\n");
    if (write(wfd, "data", 1) == -1)
        fprintf(stderr, "write() error [%m]\n");
    if (fsetxattr(wfd, "user.test", "test", 4, 0) == -1)
        fprintf(stderr, "fsetxattr() error [%m]\n");

<Prev in Thread] Current Thread [Next in Thread>