History

open-style analog of vfs_path_lookup()

new function: file_open_root(dentry, mnt, name, flags) opens the file vfs_path_lookup would arrive to. Note that name can be empty; in that case the usual requirement that dentry should be a directory is lifted. open-coded equivalents switched to it, may_open() got down exactly one caller and became static.

Al Viro committed 15 years ago

Commit 73d049a1 parent 5b6ca027 files · +77 −84Browse files

Showing the changes to kernel/sysctl_binary.c (1 of 7 files). Show all

Unified · Split

kernel/sysctl_binary.c+1−18
@@ -1321,13 +1321,11 @@ static ssize_t binary_sysctl(const int *name, int nlen, · 1320 unmodified lines
13211321 void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
13221322 {
13231323 const struct bin_table *table = NULL;
1324− struct nameidata nd;
13251324 struct vfsmount *mnt;
13261325 struct file *file;
13271326 ssize_t result;
13281327 char *pathname;
13291328 int flags;
1330− int acc_mode;
13311329
13321330 pathname = sysctl_getname(name, nlen, &table);
13331331 result = PTR_ERR(pathname);
@@ -1337,28 +1335,17 @@ static ssize_t binary_sysctl(const int *name, int nlen, · 3 unmodified lines
13371335 /* How should the sysctl be accessed? */
13381336 if (oldval && oldlen && newval && newlen) {
13391337 flags = O_RDWR;
1340− acc_mode = MAY_READ | MAY_WRITE;
13411338 } else if (newval && newlen) {
13421339 flags = O_WRONLY;
1343− acc_mode = MAY_WRITE;
13441340 } else if (oldval && oldlen) {
13451341 flags = O_RDONLY;
1346− acc_mode = MAY_READ;
13471342 } else {
13481343 result = 0;
13491344 goto out_putname;
13501345 }
13511346
13521347 mnt = current->nsproxy->pid_ns->proc_mnt;
1353− result = vfs_path_lookup(mnt->mnt_root, mnt, pathname, 0, &nd);
1354− if (result)
1355− goto out_putname;
1356−
1357− result = may_open(&nd.path, acc_mode, flags);
1358− if (result)
1359− goto out_putpath;
1360−
1361− file = dentry_open(nd.path.dentry, nd.path.mnt, flags, current_cred());
1348+ file = file_open_root(mnt->mnt_root, mnt, pathname, flags);
13621349 result = PTR_ERR(file);
13631350 if (IS_ERR(file))
13641351 goto out_putname;
@@ -1370,10 +1357,6 @@ out_putname: · 5 unmodified lines
13701357 putname(pathname);
13711358 out:
13721359 return result;
1373−
1374−out_putpath:
1375− path_put(&nd.path);
1376− goto out_putname;
13771360 }
13781361
13791362