Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

VFS: Provide empty name qstr

Provide an empty name (ie. "") qstr for general use.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

David Howells and committed by
Al Viro
cdf01226 ee416bcd

+15 -10
+6 -2
fs/dcache.c
··· 90 90 91 91 static struct kmem_cache *dentry_cache __read_mostly; 92 92 93 + const struct qstr empty_name = QSTR_INIT("", 0); 94 + EXPORT_SYMBOL(empty_name); 95 + const struct qstr slash_name = QSTR_INIT("/", 1); 96 + EXPORT_SYMBOL(slash_name); 97 + 93 98 /* 94 99 * This is the single most critical data structure when it comes 95 100 * to the dcache: the hashtable for lookups. Somebody should try ··· 1583 1578 */ 1584 1579 dentry->d_iname[DNAME_INLINE_LEN-1] = 0; 1585 1580 if (unlikely(!name)) { 1586 - static const struct qstr anon = QSTR_INIT("/", 1); 1587 - name = &anon; 1581 + name = &slash_name; 1588 1582 dname = dentry->d_iname; 1589 1583 } else if (name->len > DNAME_INLINE_LEN-1) { 1590 1584 size_t size = offsetof(struct external_name, name[1]);
+1 -2
fs/gfs2/dir.c
··· 872 872 struct buffer_head *bh; 873 873 struct gfs2_leaf *leaf; 874 874 struct gfs2_dirent *dent; 875 - struct qstr name = { .name = "" }; 876 875 struct timespec tv = current_time(inode); 877 876 878 877 error = gfs2_alloc_blocks(ip, &bn, &n, 0, NULL); ··· 895 896 leaf->lf_sec = cpu_to_be64(tv.tv_sec); 896 897 memset(leaf->lf_reserved2, 0, sizeof(leaf->lf_reserved2)); 897 898 dent = (struct gfs2_dirent *)(leaf+1); 898 - gfs2_qstr2dirent(&name, bh->b_size - sizeof(struct gfs2_leaf), dent); 899 + gfs2_qstr2dirent(&empty_name, bh->b_size - sizeof(struct gfs2_leaf), dent); 899 900 *pbh = bh; 900 901 return leaf; 901 902 }
+1 -2
fs/namei.c
··· 3400 3400 3401 3401 struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, int open_flag) 3402 3402 { 3403 - static const struct qstr name = QSTR_INIT("/", 1); 3404 3403 struct dentry *child = NULL; 3405 3404 struct inode *dir = dentry->d_inode; 3406 3405 struct inode *inode; ··· 3413 3414 if (!dir->i_op->tmpfile) 3414 3415 goto out_err; 3415 3416 error = -ENOMEM; 3416 - child = d_alloc(dentry, &name); 3417 + child = d_alloc(dentry, &slash_name); 3417 3418 if (unlikely(!child)) 3418 3419 goto out_err; 3419 3420 error = dir->i_op->tmpfile(dir, child, mode);
+1 -2
fs/nsfs.c
··· 53 53 static void *__ns_get_path(struct path *path, struct ns_common *ns) 54 54 { 55 55 struct vfsmount *mnt = nsfs_mnt; 56 - struct qstr qname = { .name = "", }; 57 56 struct dentry *dentry; 58 57 struct inode *inode; 59 58 unsigned long d; ··· 84 85 inode->i_fop = &ns_file_operations; 85 86 inode->i_private = ns; 86 87 87 - dentry = d_alloc_pseudo(mnt->mnt_sb, &qname); 88 + dentry = d_alloc_pseudo(mnt->mnt_sb, &empty_name); 88 89 if (!dentry) { 89 90 iput(inode); 90 91 return ERR_PTR(-ENOMEM);
+1 -2
fs/pipe.c
··· 739 739 struct inode *inode = get_pipe_inode(); 740 740 struct file *f; 741 741 struct path path; 742 - static struct qstr name = { .name = "" }; 743 742 744 743 if (!inode) 745 744 return -ENFILE; 746 745 747 746 err = -ENOMEM; 748 - path.dentry = d_alloc_pseudo(pipe_mnt->mnt_sb, &name); 747 + path.dentry = d_alloc_pseudo(pipe_mnt->mnt_sb, &empty_name); 749 748 if (!path.dentry) 750 749 goto err_inode; 751 750 path.mnt = mntget(pipe_mnt);
+5
include/linux/dcache.h
··· 55 55 56 56 #define QSTR_INIT(n,l) { { { .len = l } }, .name = n } 57 57 58 + extern const char empty_string[]; 59 + extern const struct qstr empty_name; 60 + extern const char slash_string[]; 61 + extern const struct qstr slash_name; 62 + 58 63 struct dentry_stat_t { 59 64 long nr_dentry; 60 65 long nr_unused;