[systemd-devel] [PATCH 1/4] Add change_attr_fd()

Lennart Poettering lennart at poettering.net
Wed Apr 8 11:47:59 PDT 2015


On Wed, 08.04.15 20:37, Lennart Poettering (lennart at poettering.net) wrote:

> On Mon, 16.03.15 20:33, Goffredo Baroncelli (kreijack at libero.it) wrote:
> 
> >  
> > +int change_attr_fd(int fd, unsigned value, unsigned mask) {
> > +        unsigned old_attr, new_attr;
> > +
> > +        assert(fd >= 0);
> > +
> > +        if (mask == 0)
> > +                return 0;
> > +
> > +        if (ioctl(fd, FS_IOC_GETFLAGS, &old_attr) < 0)
> > +                return -errno;
> > +
> > +        new_attr = (old_attr & ~mask) |(value & mask);
> > +
> > +        if (new_attr == old_attr)
> > +                return 0;
> > +
> > +        if (ioctl(fd, FS_IOC_SETFLAGS, &new_attr) < 0)
> > +                return -errno;
> > +
> > +        return 0;
> > +}
> > +
> 
> With this added chattr_fd() is kinda redundant, no?

I fixed this now.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list