aboutsummaryrefslogtreecommitdiffstats
path: root/mm
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 /mm
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 'mm')
-rw-r--r--mm/swapfile.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 14e254c768fc..90d2ed591de9 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1483,7 +1483,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1483 struct file *swap_file, *victim; 1483 struct file *swap_file, *victim;
1484 struct address_space *mapping; 1484 struct address_space *mapping;
1485 struct inode *inode; 1485 struct inode *inode;
1486 char *pathname; 1486 struct filename *pathname;
1487 int oom_score_adj; 1487 int oom_score_adj;
1488 int i, type, prev; 1488 int i, type, prev;
1489 int err; 1489 int err;
@@ -1498,8 +1498,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1498 if (IS_ERR(pathname)) 1498 if (IS_ERR(pathname))
1499 goto out; 1499 goto out;
1500 1500
1501 victim = filp_open(pathname, O_RDWR|O_LARGEFILE, 0); 1501 victim = filp_open(pathname->name, O_RDWR|O_LARGEFILE, 0);
1502 putname(pathname);
1503 err = PTR_ERR(victim); 1502 err = PTR_ERR(victim);
1504 if (IS_ERR(victim)) 1503 if (IS_ERR(victim))
1505 goto out; 1504 goto out;
@@ -1936,7 +1935,7 @@ static int setup_swap_map_and_extents(struct swap_info_struct *p,
1936SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) 1935SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1937{ 1936{
1938 struct swap_info_struct *p; 1937 struct swap_info_struct *p;
1939 char *name; 1938 struct filename *name;
1940 struct file *swap_file = NULL; 1939 struct file *swap_file = NULL;
1941 struct address_space *mapping; 1940 struct address_space *mapping;
1942 int i; 1941 int i;
@@ -1967,7 +1966,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
1967 name = NULL; 1966 name = NULL;
1968 goto bad_swap; 1967 goto bad_swap;
1969 } 1968 }
1970 swap_file = filp_open(name, O_RDWR|O_LARGEFILE, 0); 1969 swap_file = filp_open(name->name, O_RDWR|O_LARGEFILE, 0);
1971 if (IS_ERR(swap_file)) { 1970 if (IS_ERR(swap_file)) {
1972 error = PTR_ERR(swap_file); 1971 error = PTR_ERR(swap_file);
1973 swap_file = NULL; 1972 swap_file = NULL;
@@ -2053,7 +2052,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
2053 2052
2054 printk(KERN_INFO "Adding %uk swap on %s. " 2053 printk(KERN_INFO "Adding %uk swap on %s. "
2055 "Priority:%d extents:%d across:%lluk %s%s%s\n", 2054 "Priority:%d extents:%d across:%lluk %s%s%s\n",
2056 p->pages<<(PAGE_SHIFT-10), name, p->prio, 2055 p->pages<<(PAGE_SHIFT-10), name->name, p->prio,
2057 nr_extents, (unsigned long long)span<<(PAGE_SHIFT-10), 2056 nr_extents, (unsigned long long)span<<(PAGE_SHIFT-10),
2058 (p->flags & SWP_SOLIDSTATE) ? "SS" : "", 2057 (p->flags & SWP_SOLIDSTATE) ? "SS" : "",
2059 (p->flags & SWP_DISCARDABLE) ? "D" : "", 2058 (p->flags & SWP_DISCARDABLE) ? "D" : "",