Skip to content

Commit

Permalink
new helper: is_root_inode()
Browse files Browse the repository at this point in the history
replace open-coded instances

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Oct 31, 2014
1 parent ac7576f commit a740022
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
6 changes: 0 additions & 6 deletions fs/coda/coda_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ int coda_iscontrol(const char *name, size_t length)
(strncmp(name, CODA_CONTROL, CODA_CONTROLLEN) == 0));
}

/* recognize /coda inode */
int coda_isroot(struct inode *i)
{
return ( i->i_sb->s_root->d_inode == i );
}

unsigned short coda_flags_to_cflags(unsigned short flags)
{
unsigned short coda_flags = 0;
Expand Down
1 change: 0 additions & 1 deletion fs/coda/coda_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ int coda_setattr(struct dentry *, struct iattr *);

/* this file: heloers */
char *coda_f2s(struct CodaFid *f);
int coda_isroot(struct inode *i);
int coda_iscontrol(const char *name, size_t length);

void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
Expand Down
12 changes: 6 additions & 6 deletions fs/coda/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsig
}

/* control object, create inode on the fly */
if (coda_isroot(dir) && coda_iscontrol(name, length)) {
if (is_root_inode(dir) && coda_iscontrol(name, length)) {
inode = coda_cnode_makectl(sb);
type = CODA_NOCACHE;
} else {
Expand Down Expand Up @@ -195,7 +195,7 @@ static int coda_create(struct inode *dir, struct dentry *de, umode_t mode, bool
struct CodaFid newfid;
struct coda_vattr attrs;

if (coda_isroot(dir) && coda_iscontrol(name, length))
if (is_root_inode(dir) && coda_iscontrol(name, length))
return -EPERM;

error = venus_create(dir->i_sb, coda_i2f(dir), name, length,
Expand Down Expand Up @@ -227,7 +227,7 @@ static int coda_mkdir(struct inode *dir, struct dentry *de, umode_t mode)
int error;
struct CodaFid newfid;

if (coda_isroot(dir) && coda_iscontrol(name, len))
if (is_root_inode(dir) && coda_iscontrol(name, len))
return -EPERM;

attrs.va_mode = mode;
Expand Down Expand Up @@ -261,7 +261,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
int len = de->d_name.len;
int error;

if (coda_isroot(dir_inode) && coda_iscontrol(name, len))
if (is_root_inode(dir_inode) && coda_iscontrol(name, len))
return -EPERM;

error = venus_link(dir_inode->i_sb, coda_i2f(inode),
Expand All @@ -287,7 +287,7 @@ static int coda_symlink(struct inode *dir_inode, struct dentry *de,
int symlen;
int error;

if (coda_isroot(dir_inode) && coda_iscontrol(name, len))
if (is_root_inode(dir_inode) && coda_iscontrol(name, len))
return -EPERM;

symlen = strlen(symname);
Expand Down Expand Up @@ -507,7 +507,7 @@ static int coda_dentry_revalidate(struct dentry *de, unsigned int flags)
return -ECHILD;

inode = de->d_inode;
if (!inode || coda_isroot(inode))
if (!inode || is_root_inode(inode))
goto out;
if (is_bad_inode(inode))
goto bad;
Expand Down
4 changes: 2 additions & 2 deletions fs/ncpfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ ncp_single_volume(struct ncp_server *server)

static inline int ncp_is_server_root(struct inode *inode)
{
return (!ncp_single_volume(NCP_SERVER(inode)) &&
inode == inode->i_sb->s_root->d_inode);
return !ncp_single_volume(NCP_SERVER(inode)) &&
is_root_inode(inode);
}


Expand Down
5 changes: 5 additions & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2789,6 +2789,11 @@ static inline void inode_has_no_xattr(struct inode *inode)
inode->i_flags |= S_NOSEC;
}

static inline bool is_root_inode(struct inode *inode)
{
return inode == inode->i_sb->s_root->d_inode;
}

static inline bool dir_emit(struct dir_context *ctx,
const char *name, int namelen,
u64 ino, unsigned type)
Expand Down

0 comments on commit a740022

Please sign in to comment.