[GFS2] Fix attributes setting logic
authorSteven Whitehouse <swhiteho@redhat.com>
Fri, 12 May 2006 21:07:56 +0000 (17:07 -0400)
committerSteven Whitehouse <swhiteho@redhat.com>
Fri, 12 May 2006 21:07:56 +0000 (17:07 -0400)
The attributes logic for immutable was wrong so that there was
not way to remove this attribute once set. This fixes the
bug.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
fs/gfs2/ops_file.c

index c2dbc300a50cb32e85fd51ba9b792010163e493e..cf724800e0e9338f4640b27352f110da43eadea5 100644 (file)
@@ -611,8 +611,10 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
 
        gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
        error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
-       if (error)
+       if (error) {
+               gfs2_holder_uninit(&gh);
                return error;
+       }
 
        flags = ip->i_di.di_flags;
        new_flags = (flags & ~mask) | (reqflags & mask);
@@ -635,9 +637,14 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask)
                goto out;
        if (IS_APPEND(inode) && (new_flags & GFS2_DIF_APPENDONLY))
                goto out;
-       error = gfs2_repermission(inode, MAY_WRITE, NULL);
-       if (error)
+       if (((new_flags ^ flags) & GFS2_DIF_IMMUTABLE) && 
+           !capable(CAP_LINUX_IMMUTABLE))
                goto out;
+       if (!IS_IMMUTABLE(inode)) {
+               error = gfs2_repermission(inode, MAY_WRITE, NULL);
+               if (error)
+                       goto out;
+       }
 
        error = gfs2_trans_begin(sdp, RES_DINODE, 0);
        if (error)
This page took 0.026113 seconds and 5 git commands to generate.