aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-10-10 15:25:28 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-12 20:14:55 -0400
commit91a27b2a756784714e924e5e854b919273082d26 (patch)
tree3913246b7d6e62703ec915f481e3a7159393f0f0 /include/linux/fs.h
parent8e377d15078a501c4da98471f56396343c407d92 (diff)
vfs: define struct filename and have getname() return it
getname() is intended to copy pathname strings from userspace into a kernel buffer. The result is just a string in kernel space. It would however be quite helpful to be able to attach some ancillary info to the string. For instance, we could attach some audit-related info to reduce the amount of audit-related processing needed. When auditing is enabled, we could also call getname() on the string more than once and not need to recopy it from userspace. This patchset converts the getname()/putname() interfaces to return a struct instead of a string. For now, the struct just tracks the string in kernel space and the original userland pointer for it. Later, we'll add other information to the struct as it becomes convenient. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b44b4ca82164..6c93b46f46dc 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2196,6 +2196,10 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
2196#endif /* CONFIG_FILE_LOCKING */ 2196#endif /* CONFIG_FILE_LOCKING */
2197 2197
2198/* fs/open.c */ 2198/* fs/open.c */
2199struct filename {
2200 const char *name; /* pointer to actual string */
2201 const __user char *uptr; /* original userland pointer */
2202};
2199 2203
2200extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, 2204extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
2201 struct file *filp); 2205 struct file *filp);
@@ -2208,7 +2212,9 @@ extern struct file *file_open_root(struct dentry *, struct vfsmount *,
2208 const char *, int); 2212 const char *, int);
2209extern struct file * dentry_open(const struct path *, int, const struct cred *); 2213extern struct file * dentry_open(const struct path *, int, const struct cred *);
2210extern int filp_close(struct file *, fl_owner_t id); 2214extern int filp_close(struct file *, fl_owner_t id);
2211extern char * getname(const char __user *); 2215
2216extern struct filename *getname(const char __user *);
2217
2212enum { 2218enum {
2213 FILE_CREATED = 1, 2219 FILE_CREATED = 1,
2214 FILE_OPENED = 2 2220 FILE_OPENED = 2
@@ -2228,12 +2234,14 @@ extern void __init vfs_caches_init(unsigned long);
2228 2234
2229extern struct kmem_cache *names_cachep; 2235extern struct kmem_cache *names_cachep;
2230 2236
2237extern void final_putname(struct filename *name);
2238
2231#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) 2239#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL)
2232#define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 2240#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
2233#ifndef CONFIG_AUDITSYSCALL 2241#ifndef CONFIG_AUDITSYSCALL
2234#define putname(name) __putname(name) 2242#define putname(name) final_putname(name)
2235#else 2243#else
2236extern void putname(const char *name); 2244extern void putname(struct filename *name);
2237#endif 2245#endif
2238 2246
2239#ifdef CONFIG_BLOCK 2247#ifdef CONFIG_BLOCK