diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2009-04-02 21:17:03 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-05-09 10:49:42 -0400 |
commit | e24977d45f45d1675e050dc1a0aaf4bfc4ca9866 (patch) | |
tree | ee39b590596e9ca6cd18b8ece11a1f6d24278c29 | |
parent | 6b3304b531704711286c3359b06922b83fdba015 (diff) |
Reduce path_lookup() abuses
... use kern_path() where possible
[folded a fix from rdd]
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/scsi/osd/osd_uld.c | 20 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 8 | ||||
-rw-r--r-- | security/tomoyo/common.c | 6 | ||||
-rw-r--r-- | security/tomoyo/realpath.c | 16 |
4 files changed, 25 insertions, 25 deletions
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c index f644c9571eab..22b59e13ba83 100644 --- a/drivers/scsi/osd/osd_uld.c +++ b/drivers/scsi/osd/osd_uld.c | |||
@@ -173,26 +173,26 @@ static const struct file_operations osd_fops = { | |||
173 | .unlocked_ioctl = osd_uld_ioctl, | 173 | .unlocked_ioctl = osd_uld_ioctl, |
174 | }; | 174 | }; |
175 | 175 | ||
176 | struct osd_dev *osduld_path_lookup(const char *path) | 176 | struct osd_dev *osduld_path_lookup(const char *name) |
177 | { | 177 | { |
178 | struct nameidata nd; | 178 | struct path path; |
179 | struct inode *inode; | 179 | struct inode *inode; |
180 | struct cdev *cdev; | 180 | struct cdev *cdev; |
181 | struct osd_uld_device *uninitialized_var(oud); | 181 | struct osd_uld_device *uninitialized_var(oud); |
182 | int error; | 182 | int error; |
183 | 183 | ||
184 | if (!path || !*path) { | 184 | if (!name || !*name) { |
185 | OSD_ERR("Mount with !path || !*path\n"); | 185 | OSD_ERR("Mount with !path || !*path\n"); |
186 | return ERR_PTR(-EINVAL); | 186 | return ERR_PTR(-EINVAL); |
187 | } | 187 | } |
188 | 188 | ||
189 | error = path_lookup(path, LOOKUP_FOLLOW, &nd); | 189 | error = kern_path(name, LOOKUP_FOLLOW, &path); |
190 | if (error) { | 190 | if (error) { |
191 | OSD_ERR("path_lookup of %s faild=>%d\n", path, error); | 191 | OSD_ERR("path_lookup of %s failed=>%d\n", name, error); |
192 | return ERR_PTR(error); | 192 | return ERR_PTR(error); |
193 | } | 193 | } |
194 | 194 | ||
195 | inode = nd.path.dentry->d_inode; | 195 | inode = path.dentry->d_inode; |
196 | error = -EINVAL; /* Not the right device e.g osd_uld_device */ | 196 | error = -EINVAL; /* Not the right device e.g osd_uld_device */ |
197 | if (!S_ISCHR(inode->i_mode)) { | 197 | if (!S_ISCHR(inode->i_mode)) { |
198 | OSD_DEBUG("!S_ISCHR()\n"); | 198 | OSD_DEBUG("!S_ISCHR()\n"); |
@@ -202,15 +202,15 @@ struct osd_dev *osduld_path_lookup(const char *path) | |||
202 | cdev = inode->i_cdev; | 202 | cdev = inode->i_cdev; |
203 | if (!cdev) { | 203 | if (!cdev) { |
204 | OSD_ERR("Before mounting an OSD Based filesystem\n"); | 204 | OSD_ERR("Before mounting an OSD Based filesystem\n"); |
205 | OSD_ERR(" user-mode must open+close the %s device\n", path); | 205 | OSD_ERR(" user-mode must open+close the %s device\n", name); |
206 | OSD_ERR(" Example: bash: echo < %s\n", path); | 206 | OSD_ERR(" Example: bash: echo < %s\n", name); |
207 | goto out; | 207 | goto out; |
208 | } | 208 | } |
209 | 209 | ||
210 | /* The Magic wand. Is it our char-dev */ | 210 | /* The Magic wand. Is it our char-dev */ |
211 | /* TODO: Support sg devices */ | 211 | /* TODO: Support sg devices */ |
212 | if (cdev->owner != THIS_MODULE) { | 212 | if (cdev->owner != THIS_MODULE) { |
213 | OSD_ERR("Error mounting %s - is not an OSD device\n", path); | 213 | OSD_ERR("Error mounting %s - is not an OSD device\n", name); |
214 | goto out; | 214 | goto out; |
215 | } | 215 | } |
216 | 216 | ||
@@ -220,7 +220,7 @@ struct osd_dev *osduld_path_lookup(const char *path) | |||
220 | error = 0; | 220 | error = 0; |
221 | 221 | ||
222 | out: | 222 | out: |
223 | path_put(&nd.path); | 223 | path_put(&path); |
224 | return error ? ERR_PTR(error) : &oud->od; | 224 | return error ? ERR_PTR(error) : &oud->od; |
225 | } | 225 | } |
226 | EXPORT_SYMBOL(osduld_path_lookup); | 226 | EXPORT_SYMBOL(osduld_path_lookup); |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 650a730707b7..1ff9473ea753 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -1282,21 +1282,21 @@ static int gfs2_get_sb(struct file_system_type *fs_type, int flags, | |||
1282 | static struct super_block *get_gfs2_sb(const char *dev_name) | 1282 | static struct super_block *get_gfs2_sb(const char *dev_name) |
1283 | { | 1283 | { |
1284 | struct super_block *sb; | 1284 | struct super_block *sb; |
1285 | struct nameidata nd; | 1285 | struct path path; |
1286 | int error; | 1286 | int error; |
1287 | 1287 | ||
1288 | error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); | 1288 | error = kern_path(dev_name, LOOKUP_FOLLOW, &path); |
1289 | if (error) { | 1289 | if (error) { |
1290 | printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n", | 1290 | printk(KERN_WARNING "GFS2: path_lookup on %s returned error %d\n", |
1291 | dev_name, error); | 1291 | dev_name, error); |
1292 | return NULL; | 1292 | return NULL; |
1293 | } | 1293 | } |
1294 | sb = nd.path.dentry->d_inode->i_sb; | 1294 | sb = path.dentry->d_inode->i_sb; |
1295 | if (sb && (sb->s_type == &gfs2_fs_type)) | 1295 | if (sb && (sb->s_type == &gfs2_fs_type)) |
1296 | atomic_inc(&sb->s_active); | 1296 | atomic_inc(&sb->s_active); |
1297 | else | 1297 | else |
1298 | sb = NULL; | 1298 | sb = NULL; |
1299 | path_put(&nd.path); | 1299 | path_put(&path); |
1300 | return sb; | 1300 | return sb; |
1301 | } | 1301 | } |
1302 | 1302 | ||
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c index d4d41b3efc7c..ddfb9cccf468 100644 --- a/security/tomoyo/common.c +++ b/security/tomoyo/common.c | |||
@@ -1720,14 +1720,14 @@ static bool tomoyo_policy_loader_exists(void) | |||
1720 | * policies are not loaded yet. | 1720 | * policies are not loaded yet. |
1721 | * Thus, let do_execve() call this function everytime. | 1721 | * Thus, let do_execve() call this function everytime. |
1722 | */ | 1722 | */ |
1723 | struct nameidata nd; | 1723 | struct path path; |
1724 | 1724 | ||
1725 | if (path_lookup(tomoyo_loader, LOOKUP_FOLLOW, &nd)) { | 1725 | if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) { |
1726 | printk(KERN_INFO "Not activating Mandatory Access Control now " | 1726 | printk(KERN_INFO "Not activating Mandatory Access Control now " |
1727 | "since %s doesn't exist.\n", tomoyo_loader); | 1727 | "since %s doesn't exist.\n", tomoyo_loader); |
1728 | return false; | 1728 | return false; |
1729 | } | 1729 | } |
1730 | path_put(&nd.path); | 1730 | path_put(&path); |
1731 | return true; | 1731 | return true; |
1732 | } | 1732 | } |
1733 | 1733 | ||
diff --git a/security/tomoyo/realpath.c b/security/tomoyo/realpath.c index bf8e2b451687..40927a84cb6e 100644 --- a/security/tomoyo/realpath.c +++ b/security/tomoyo/realpath.c | |||
@@ -165,11 +165,11 @@ char *tomoyo_realpath_from_path(struct path *path) | |||
165 | */ | 165 | */ |
166 | char *tomoyo_realpath(const char *pathname) | 166 | char *tomoyo_realpath(const char *pathname) |
167 | { | 167 | { |
168 | struct nameidata nd; | 168 | struct path path; |
169 | 169 | ||
170 | if (pathname && path_lookup(pathname, LOOKUP_FOLLOW, &nd) == 0) { | 170 | if (pathname && kern_path(pathname, LOOKUP_FOLLOW, &path) == 0) { |
171 | char *buf = tomoyo_realpath_from_path(&nd.path); | 171 | char *buf = tomoyo_realpath_from_path(&path); |
172 | path_put(&nd.path); | 172 | path_put(&path); |
173 | return buf; | 173 | return buf; |
174 | } | 174 | } |
175 | return NULL; | 175 | return NULL; |
@@ -184,11 +184,11 @@ char *tomoyo_realpath(const char *pathname) | |||
184 | */ | 184 | */ |
185 | char *tomoyo_realpath_nofollow(const char *pathname) | 185 | char *tomoyo_realpath_nofollow(const char *pathname) |
186 | { | 186 | { |
187 | struct nameidata nd; | 187 | struct path path; |
188 | 188 | ||
189 | if (pathname && path_lookup(pathname, 0, &nd) == 0) { | 189 | if (pathname && kern_path(pathname, 0, &path) == 0) { |
190 | char *buf = tomoyo_realpath_from_path(&nd.path); | 190 | char *buf = tomoyo_realpath_from_path(&path); |
191 | path_put(&nd.path); | 191 | path_put(&path); |
192 | return buf; | 192 | return buf; |
193 | } | 193 | } |
194 | return NULL; | 194 | return NULL; |