namei.c (3d8a00d2099ebc6d5a6e95fadaf861709d9919a8) | namei.c (d95852777bc8ba6b3ad3397d495c5f9dd8ca8383) |
---|---|
1/* 2 * linux/fs/namei.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * Some corrections by tytso. --- 2190 unchanged lines hidden (view full) --- 2199 bool *want_write, bool need_lookup, 2200 int *opened) 2201{ 2202 struct inode *dir = nd->path.dentry->d_inode; 2203 unsigned open_flag = open_to_namei_flags(op->open_flag); 2204 umode_t mode; 2205 int error; 2206 int acc_mode; | 1/* 2 * linux/fs/namei.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * Some corrections by tytso. --- 2190 unchanged lines hidden (view full) --- 2199 bool *want_write, bool need_lookup, 2200 int *opened) 2201{ 2202 struct inode *dir = nd->path.dentry->d_inode; 2203 unsigned open_flag = open_to_namei_flags(op->open_flag); 2204 umode_t mode; 2205 int error; 2206 int acc_mode; |
2207 struct file *filp; | 2207 struct file *filp = NULL; |
2208 int create_error = 0; 2209 struct dentry *const DENTRY_NOT_SET = (void *) -1UL; 2210 2211 BUG_ON(dentry->d_inode); 2212 2213 /* Don't create child dentry for a dead directory. */ 2214 if (unlikely(IS_DEADDIR(dir))) { 2215 filp = ERR_PTR(-ENOENT); --- 50 unchanged lines hidden (view full) --- 2266 } 2267 } 2268 2269 if (nd->flags & LOOKUP_DIRECTORY) 2270 open_flag |= O_DIRECTORY; 2271 2272 od->dentry = DENTRY_NOT_SET; 2273 od->mnt = nd->path.mnt; | 2208 int create_error = 0; 2209 struct dentry *const DENTRY_NOT_SET = (void *) -1UL; 2210 2211 BUG_ON(dentry->d_inode); 2212 2213 /* Don't create child dentry for a dead directory. */ 2214 if (unlikely(IS_DEADDIR(dir))) { 2215 filp = ERR_PTR(-ENOENT); --- 50 unchanged lines hidden (view full) --- 2266 } 2267 } 2268 2269 if (nd->flags & LOOKUP_DIRECTORY) 2270 open_flag |= O_DIRECTORY; 2271 2272 od->dentry = DENTRY_NOT_SET; 2273 od->mnt = nd->path.mnt; |
2274 filp = dir->i_op->atomic_open(dir, dentry, od, open_flag, mode, | 2274 error = dir->i_op->atomic_open(dir, dentry, od, open_flag, mode, |
2275 opened); | 2275 opened); |
2276 if (IS_ERR(filp)) { | 2276 if (error < 0) { |
2277 if (WARN_ON(od->dentry != DENTRY_NOT_SET)) 2278 dput(od->dentry); 2279 | 2277 if (WARN_ON(od->dentry != DENTRY_NOT_SET)) 2278 dput(od->dentry); 2279 |
2280 if (create_error && PTR_ERR(filp) == -ENOENT) 2281 filp = ERR_PTR(create_error); | 2280 if (create_error && error == -ENOENT) 2281 error = create_error; 2282 filp = ERR_PTR(error); |
2282 goto out; 2283 } 2284 2285 acc_mode = op->acc_mode; 2286 if (*opened & FILE_CREATED) { 2287 fsnotify_create(dir, dentry); 2288 acc_mode = MAY_OPEN; 2289 } 2290 | 2283 goto out; 2284 } 2285 2286 acc_mode = op->acc_mode; 2287 if (*opened & FILE_CREATED) { 2288 fsnotify_create(dir, dentry); 2289 acc_mode = MAY_OPEN; 2290 } 2291 |
2291 if (!filp) { | 2292 if (error) { /* returned 1, that is */ |
2292 if (WARN_ON(od->dentry == DENTRY_NOT_SET)) { 2293 filp = ERR_PTR(-EIO); 2294 goto out; 2295 } 2296 if (od->dentry) { 2297 dput(dentry); 2298 dentry = od->dentry; 2299 } 2300 goto looked_up; 2301 } 2302 2303 /* 2304 * We didn't have the inode before the open, so check open permission 2305 * here. 2306 */ | 2293 if (WARN_ON(od->dentry == DENTRY_NOT_SET)) { 2294 filp = ERR_PTR(-EIO); 2295 goto out; 2296 } 2297 if (od->dentry) { 2298 dput(dentry); 2299 dentry = od->dentry; 2300 } 2301 goto looked_up; 2302 } 2303 2304 /* 2305 * We didn't have the inode before the open, so check open permission 2306 * here. 2307 */ |
2308 filp = od->filp; |
|
2307 error = may_open(&filp->f_path, acc_mode, open_flag); 2308 if (error) { 2309 fput(filp); 2310 filp = ERR_PTR(error); 2311 } 2312 2313out: 2314 dput(dentry); --- 1484 unchanged lines hidden --- | 2309 error = may_open(&filp->f_path, acc_mode, open_flag); 2310 if (error) { 2311 fput(filp); 2312 filp = ERR_PTR(error); 2313 } 2314 2315out: 2316 dput(dentry); --- 1484 unchanged lines hidden --- |