diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-08-24 12:08:17 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-08-24 12:10:17 -0400 |
commit | 118b23022512eb2f41ce42db70dc0568d00be4ba (patch) | |
tree | ec36d1868c21403ce009182ae8acfeae2ea2c3d0 | |
parent | b36f4be3de1b123d8601de062e7dbfc904f305fb (diff) |
cope with potentially long ->d_dname() output for shmem/hugetlb
dynamic_dname() is both too much and too little for those - the
output may be well in excess of 64 bytes dynamic_dname() assumes
to be enough (thanks to ashmem feeding really long names to
shmem_file_setup()) and vsnprintf() is an overkill for those
guys.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/dcache.c | 11 | ||||
-rw-r--r-- | fs/hugetlbfs/inode.c | 8 | ||||
-rw-r--r-- | include/linux/dcache.h | 1 | ||||
-rw-r--r-- | mm/shmem.c | 8 |
4 files changed, 14 insertions, 14 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 87bdb5329c3c..83cfb834db03 100644 --- a/fs/dcache.c +++ b/fs/dcache.c | |||
@@ -2724,6 +2724,17 @@ char *dynamic_dname(struct dentry *dentry, char *buffer, int buflen, | |||
2724 | return memcpy(buffer, temp, sz); | 2724 | return memcpy(buffer, temp, sz); |
2725 | } | 2725 | } |
2726 | 2726 | ||
2727 | char *simple_dname(struct dentry *dentry, char *buffer, int buflen) | ||
2728 | { | ||
2729 | char *end = buffer + buflen; | ||
2730 | /* these dentries are never renamed, so d_lock is not needed */ | ||
2731 | if (prepend(&end, &buflen, " (deleted)", 11) || | ||
2732 | prepend_name(&end, &buflen, &dentry->d_name) || | ||
2733 | prepend(&end, &buflen, "/", 1)) | ||
2734 | end = ERR_PTR(-ENAMETOOLONG); | ||
2735 | return end; | ||
2736 | } | ||
2737 | |||
2727 | /* | 2738 | /* |
2728 | * Write full pathname from the root of the filesystem into the buffer. | 2739 | * Write full pathname from the root of the filesystem into the buffer. |
2729 | */ | 2740 | */ |
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 34423978b170..d19b30ababf1 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
@@ -926,14 +926,8 @@ static int get_hstate_idx(int page_size_log) | |||
926 | return h - hstates; | 926 | return h - hstates; |
927 | } | 927 | } |
928 | 928 | ||
929 | static char *hugetlb_dname(struct dentry *dentry, char *buffer, int buflen) | ||
930 | { | ||
931 | return dynamic_dname(dentry, buffer, buflen, "/%s (deleted)", | ||
932 | dentry->d_name.name); | ||
933 | } | ||
934 | |||
935 | static struct dentry_operations anon_ops = { | 929 | static struct dentry_operations anon_ops = { |
936 | .d_dname = hugetlb_dname | 930 | .d_dname = simple_dname |
937 | }; | 931 | }; |
938 | 932 | ||
939 | /* | 933 | /* |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index b90337c9d468..4a12532da8c4 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -336,6 +336,7 @@ extern int d_validate(struct dentry *, struct dentry *); | |||
336 | * helper function for dentry_operations.d_dname() members | 336 | * helper function for dentry_operations.d_dname() members |
337 | */ | 337 | */ |
338 | extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); | 338 | extern char *dynamic_dname(struct dentry *, char *, int, const char *, ...); |
339 | extern char *simple_dname(struct dentry *, char *, int); | ||
339 | 340 | ||
340 | extern char *__d_path(const struct path *, const struct path *, char *, int); | 341 | extern char *__d_path(const struct path *, const struct path *, char *, int); |
341 | extern char *d_absolute_path(const struct path *, char *, int); | 342 | extern char *d_absolute_path(const struct path *, char *, int); |
diff --git a/mm/shmem.c b/mm/shmem.c index 8335dbd3fc35..e43dc555069d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
@@ -2909,14 +2909,8 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range); | |||
2909 | 2909 | ||
2910 | /* common code */ | 2910 | /* common code */ |
2911 | 2911 | ||
2912 | static char *shmem_dname(struct dentry *dentry, char *buffer, int buflen) | ||
2913 | { | ||
2914 | return dynamic_dname(dentry, buffer, buflen, "/%s (deleted)", | ||
2915 | dentry->d_name.name); | ||
2916 | } | ||
2917 | |||
2918 | static struct dentry_operations anon_ops = { | 2912 | static struct dentry_operations anon_ops = { |
2919 | .d_dname = shmem_dname | 2913 | .d_dname = simple_dname |
2920 | }; | 2914 | }; |
2921 | 2915 | ||
2922 | /** | 2916 | /** |