Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146929
b: refs/heads/master
c: 87ec217
h: refs/heads/master
i:
  146927: fb26920
v: v3
  • Loading branch information
Steven Whitehouse committed May 22, 2009
1 parent 2fe0d4a commit 8c88458
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 536baf02f650f4547f105386878b4736fbc181e8
refs/heads/master: 87ec21741138bb42e7f943bb142b1d8567c10925
39 changes: 0 additions & 39 deletions trunk/fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,45 +1046,6 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name,
return ERR_PTR(error);
}


/*
* gfs2_unlink_ok - check to see that a inode is still in a directory
* @dip: the directory
* @name: the name of the file
* @ip: the inode
*
* Assumes that the lock on (at least) @dip is held.
*
* Returns: 0 if the parent/child relationship is correct, errno if it isn't
*/

int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
const struct gfs2_inode *ip)
{
int error;

if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode))
return -EPERM;

if ((dip->i_inode.i_mode & S_ISVTX) &&
dip->i_inode.i_uid != current_fsuid() &&
ip->i_inode.i_uid != current_fsuid() && !capable(CAP_FOWNER))
return -EPERM;

if (IS_APPEND(&dip->i_inode))
return -EPERM;

error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC);
if (error)
return error;

error = gfs2_dir_check(&dip->i_inode, name, ip);
if (error)
return error;

return 0;
}

static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
{
struct buffer_head *dibh;
Expand Down
2 changes: 0 additions & 2 deletions trunk/fs/gfs2/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ extern struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
extern struct inode *gfs2_createi(struct gfs2_holder *ghs,
const struct qstr *name,
unsigned int mode, dev_t dev);
extern int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
const struct gfs2_inode *ip);
extern int gfs2_permission(struct inode *inode, int mask);
extern int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
extern struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
Expand Down
38 changes: 38 additions & 0 deletions trunk/fs/gfs2/ops_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,44 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
return error;
}

/*
* gfs2_unlink_ok - check to see that a inode is still in a directory
* @dip: the directory
* @name: the name of the file
* @ip: the inode
*
* Assumes that the lock on (at least) @dip is held.
*
* Returns: 0 if the parent/child relationship is correct, errno if it isn't
*/

static int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
const struct gfs2_inode *ip)
{
int error;

if (IS_IMMUTABLE(&ip->i_inode) || IS_APPEND(&ip->i_inode))
return -EPERM;

if ((dip->i_inode.i_mode & S_ISVTX) &&
dip->i_inode.i_uid != current_fsuid() &&
ip->i_inode.i_uid != current_fsuid() && !capable(CAP_FOWNER))
return -EPERM;

if (IS_APPEND(&dip->i_inode))
return -EPERM;

error = gfs2_permission(&dip->i_inode, MAY_WRITE | MAY_EXEC);
if (error)
return error;

error = gfs2_dir_check(&dip->i_inode, name, ip);
if (error)
return error;

return 0;
}

/**
* gfs2_unlink - Unlink a file
* @dir: The inode of the directory containing the file to unlink
Expand Down

0 comments on commit 8c88458

Please sign in to comment.