Skip to content

Commit

Permalink
useful constants: struct qstr for ".."
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Apr 16, 2021
1 parent d692d39 commit 80e5d1f
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 17 deletions.
2 changes: 2 additions & 0 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const struct qstr empty_name = QSTR_INIT("", 0);
EXPORT_SYMBOL(empty_name);
const struct qstr slash_name = QSTR_INIT("/", 1);
EXPORT_SYMBOL(slash_name);
const struct qstr dotdot_name = QSTR_INIT("..", 2);
EXPORT_SYMBOL(dotdot_name);

/*
* This is the single most critical data structure when it comes
Expand Down
3 changes: 1 addition & 2 deletions fs/ext2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, uns

struct dentry *ext2_get_parent(struct dentry *child)
{
struct qstr dotdot = QSTR_INIT("..", 2);
ino_t ino;
int res;

res = ext2_inode_by_name(d_inode(child), &dotdot, &ino);
res = ext2_inode_by_name(d_inode(child), &dotdot_name, &ino);
if (res)
return ERR_PTR(res);

Expand Down
3 changes: 1 addition & 2 deletions fs/ext4/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1739,11 +1739,10 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi
struct dentry *ext4_get_parent(struct dentry *child)
{
__u32 ino;
static const struct qstr dotdot = QSTR_INIT("..", 2);
struct ext4_dir_entry_2 * de;
struct buffer_head *bh;

bh = ext4_find_entry(d_inode(child), &dotdot, &de, NULL);
bh = ext4_find_entry(d_inode(child), &dotdot_name, &de, NULL);
if (IS_ERR(bh))
return ERR_CAST(bh);
if (!bh)
Expand Down
4 changes: 1 addition & 3 deletions fs/f2fs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,7 @@ struct f2fs_dir_entry *f2fs_find_entry(struct inode *dir,

struct f2fs_dir_entry *f2fs_parent_dir(struct inode *dir, struct page **p)
{
struct qstr dotdot = QSTR_INIT("..", 2);

return f2fs_find_entry(dir, &dotdot, p);
return f2fs_find_entry(dir, &dotdot_name, p);
}

ino_t f2fs_inode_by_name(struct inode *dir, const struct qstr *qstr,
Expand Down
3 changes: 1 addition & 2 deletions fs/f2fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,8 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,

struct dentry *f2fs_get_parent(struct dentry *child)
{
struct qstr dotdot = QSTR_INIT("..", 2);
struct page *page;
unsigned long ino = f2fs_inode_by_name(d_inode(child), &dotdot, &page);
unsigned long ino = f2fs_inode_by_name(d_inode(child), &dotdot_name, &page);
if (!ino) {
if (IS_ERR(page))
return ERR_CAST(page);
Expand Down
3 changes: 1 addition & 2 deletions fs/fuse/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,14 +872,13 @@ static struct dentry *fuse_get_parent(struct dentry *child)
struct inode *inode;
struct dentry *parent;
struct fuse_entry_out outarg;
const struct qstr name = QSTR_INIT("..", 2);
int err;

if (!fc->export_support)
return ERR_PTR(-ESTALE);

err = fuse_lookup_name(child_inode->i_sb, get_node_id(child_inode),
&name, &outarg, &inode);
&dotdot_name, &outarg, &inode);
if (err) {
if (err == -ENOENT)
return ERR_PTR(-ESTALE);
Expand Down
3 changes: 1 addition & 2 deletions fs/nilfs2/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,10 +440,9 @@ static struct dentry *nilfs_get_parent(struct dentry *child)
{
unsigned long ino;
struct inode *inode;
struct qstr dotdot = QSTR_INIT("..", 2);
struct nilfs_root *root;

ino = nilfs_inode_by_name(d_inode(child), &dotdot);
ino = nilfs_inode_by_name(d_inode(child), &dotdot_name);
if (!ino)
return ERR_PTR(-ENOENT);

Expand Down
3 changes: 1 addition & 2 deletions fs/udf/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,11 +1215,10 @@ static struct dentry *udf_get_parent(struct dentry *child)
{
struct kernel_lb_addr tloc;
struct inode *inode = NULL;
struct qstr dotdot = QSTR_INIT("..", 2);
struct fileIdentDesc cfi;
struct udf_fileident_bh fibh;

if (!udf_find_entry(d_inode(child), &dotdot, &fibh, &cfi))
if (!udf_find_entry(d_inode(child), &dotdot_name, &fibh, &cfi))
return ERR_PTR(-EACCES);

if (fibh.sbh != fibh.ebh)
Expand Down
3 changes: 1 addition & 2 deletions fs/ufs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ static struct dentry *ufs_fh_to_parent(struct super_block *sb, struct fid *fid,

static struct dentry *ufs_get_parent(struct dentry *child)
{
struct qstr dot_dot = QSTR_INIT("..", 2);
ino_t ino;

ino = ufs_inode_by_name(d_inode(child), &dot_dot);
ino = ufs_inode_by_name(d_inode(child), &dotdot_name);
if (!ino)
return ERR_PTR(-ENOENT);
return d_obtain_alias(ufs_iget(child->d_sb, ino));
Expand Down
1 change: 1 addition & 0 deletions include/linux/dcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct qstr {

extern const struct qstr empty_name;
extern const struct qstr slash_name;
extern const struct qstr dotdot_name;

struct dentry_stat_t {
long nr_dentry;
Expand Down

0 comments on commit 80e5d1f

Please sign in to comment.