dir.c (c203e45f069af47ca7623e4dcd8c00bfba2722e4) dir.c (0de6256daafa3a97a269995e9b29f956bd419bbf)
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7*/
8

--- 225 unchanged lines hidden (view full) ---

234 return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) ||
235 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m);
236}
237
238/*
239 * Add a directory inode to a dentry, ensuring that no other dentry
240 * refers to this inode. Called with fc->inst_mutex.
241 */
1/*
2 FUSE: Filesystem in Userspace
3 Copyright (C) 2001-2006 Miklos Szeredi <miklos@szeredi.hu>
4
5 This program can be distributed under the terms of the GNU GPL.
6 See the file COPYING.
7*/
8

--- 225 unchanged lines hidden (view full) ---

234 return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) ||
235 S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m);
236}
237
238/*
239 * Add a directory inode to a dentry, ensuring that no other dentry
240 * refers to this inode. Called with fc->inst_mutex.
241 */
242static int fuse_d_add_directory(struct dentry *entry, struct inode *inode)
242static struct dentry *fuse_d_add_directory(struct dentry *entry,
243 struct inode *inode)
243{
244 struct dentry *alias = d_find_alias(inode);
244{
245 struct dentry *alias = d_find_alias(inode);
245 if (alias) {
246 if (alias && !(alias->d_flags & DCACHE_DISCONNECTED)) {
246 /* This tries to shrink the subtree below alias */
247 fuse_invalidate_entry(alias);
248 dput(alias);
249 if (!list_empty(&inode->i_dentry))
247 /* This tries to shrink the subtree below alias */
248 fuse_invalidate_entry(alias);
249 dput(alias);
250 if (!list_empty(&inode->i_dentry))
250 return -EBUSY;
251 return ERR_PTR(-EBUSY);
252 } else {
253 dput(alias);
251 }
254 }
252 d_add(entry, inode);
253 return 0;
255 return d_splice_alias(inode, entry);
254}
255
256static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
257 struct nameidata *nd)
258{
259 int err;
260 struct fuse_entry_out outarg;
261 struct inode *inode = NULL;
256}
257
258static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry,
259 struct nameidata *nd)
260{
261 int err;
262 struct fuse_entry_out outarg;
263 struct inode *inode = NULL;
264 struct dentry *newent;
262 struct fuse_conn *fc = get_fuse_conn(dir);
263 struct fuse_req *req;
264 struct fuse_req *forget_req;
265 u64 attr_version;
266
267 if (entry->d_name.len > FUSE_NAME_MAX)
268 return ERR_PTR(-ENAMETOOLONG);
269

--- 28 unchanged lines hidden (view full) ---

298 }
299 }
300 fuse_put_request(fc, forget_req);
301 if (err && err != -ENOENT)
302 return ERR_PTR(err);
303
304 if (inode && S_ISDIR(inode->i_mode)) {
305 mutex_lock(&fc->inst_mutex);
265 struct fuse_conn *fc = get_fuse_conn(dir);
266 struct fuse_req *req;
267 struct fuse_req *forget_req;
268 u64 attr_version;
269
270 if (entry->d_name.len > FUSE_NAME_MAX)
271 return ERR_PTR(-ENAMETOOLONG);
272

--- 28 unchanged lines hidden (view full) ---

301 }
302 }
303 fuse_put_request(fc, forget_req);
304 if (err && err != -ENOENT)
305 return ERR_PTR(err);
306
307 if (inode && S_ISDIR(inode->i_mode)) {
308 mutex_lock(&fc->inst_mutex);
306 err = fuse_d_add_directory(entry, inode);
309 newent = fuse_d_add_directory(entry, inode);
307 mutex_unlock(&fc->inst_mutex);
310 mutex_unlock(&fc->inst_mutex);
308 if (err) {
311 if (IS_ERR(newent)) {
309 iput(inode);
312 iput(inode);
310 return ERR_PTR(err);
313 return newent;
311 }
312 } else
314 }
315 } else
313 d_add(entry, inode);
316 newent = d_splice_alias(inode, entry);
314
317
318 entry = newent ? newent : entry;
315 entry->d_op = &fuse_dentry_operations;
316 if (!err)
317 fuse_change_entry_timeout(entry, &outarg);
318 else
319 fuse_invalidate_entry_cache(entry);
319 entry->d_op = &fuse_dentry_operations;
320 if (!err)
321 fuse_change_entry_timeout(entry, &outarg);
322 else
323 fuse_invalidate_entry_cache(entry);
320 return NULL;
324 return newent;
321}
322
323/*
324 * Synchronous release for the case when something goes wrong in CREATE_OPEN
325 */
326static void fuse_sync_release(struct fuse_conn *fc, struct fuse_file *ff,
327 u64 nodeid, int flags)
328{

--- 1197 unchanged lines hidden ---
325}
326
327/*
328 * Synchronous release for the case when something goes wrong in CREATE_OPEN
329 */
330static void fuse_sync_release(struct fuse_conn *fc, struct fuse_file *ff,
331 u64 nodeid, int flags)
332{

--- 1197 unchanged lines hidden ---