Lines Matching refs:dentry

45 static int debugfs_setattr(struct dentry *dentry, struct iattr *ia)
54 return simple_setattr(dentry, ia);
183 static int debugfs_show_options(struct seq_file *m, struct dentry *root)
214 static void debugfs_release_dentry(struct dentry *dentry)
216 struct debugfs_fsdata *fsd = dentry->d_fsdata;
226 struct debugfs_fsdata *fsd = path->dentry->d_fsdata;
228 return fsd->automount(path->dentry, d_inode(path->dentry)->i_private);
271 static struct dentry *debug_mount(struct file_system_type *fs_type,
292 * @parent: a pointer to the parent dentry of the file.
294 * This function will return a pointer to a dentry if it succeeds. If the file
296 * dentry must be passed to dput() when it is no longer needed.
301 struct dentry *debugfs_lookup(const char *name, struct dentry *parent)
303 struct dentry *dentry;
311 dentry = lookup_positive_unlocked(name, parent, strlen(name));
312 if (IS_ERR(dentry))
314 return dentry;
318 static struct dentry *start_creating(const char *name, struct dentry *parent)
320 struct dentry *dentry;
342 * We need the root dentry to do this, which is in the super
351 dentry = ERR_PTR(-ENOENT);
353 dentry = lookup_one_len(name, parent, strlen(name));
354 if (!IS_ERR(dentry) && d_really_is_positive(dentry)) {
355 if (d_is_dir(dentry))
361 dput(dentry);
362 dentry = ERR_PTR(-EEXIST);
365 if (IS_ERR(dentry)) {
370 return dentry;
373 static struct dentry *failed_creating(struct dentry *dentry)
375 inode_unlock(d_inode(dentry->d_parent));
376 dput(dentry);
381 static struct dentry *end_creating(struct dentry *dentry)
383 inode_unlock(d_inode(dentry->d_parent));
384 return dentry;
387 static struct dentry *__debugfs_create_file(const char *name, umode_t mode,
388 struct dentry *parent, void *data,
392 struct dentry *dentry;
398 dentry = start_creating(name, parent);
400 if (IS_ERR(dentry))
401 return dentry;
404 failed_creating(dentry);
408 inode = debugfs_get_inode(dentry->d_sb);
412 return failed_creating(dentry);
420 dentry->d_fsdata = (void *)((unsigned long)real_fops |
423 d_instantiate(dentry, inode);
424 fsnotify_create(d_inode(dentry->d_parent), dentry);
425 return end_creating(dentry);
432 * @parent: a pointer to the parent dentry for this file. This should be a
433 * directory dentry if set. If this parameter is NULL, then the
446 * This function will return a pointer to a dentry if it succeeds. This
455 struct dentry *debugfs_create_file(const char *name, umode_t mode,
456 struct dentry *parent, void *data,
471 * @parent: a pointer to the parent dentry for this file. This should be a
472 * directory dentry if set. If this parameter is NULL, then the
494 struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
495 struct dentry *parent, void *data,
510 * @parent: a pointer to the parent dentry for this file. This should be a
511 * directory dentry if set. If this parameter is NULL, then the
526 struct dentry *parent, void *data,
530 struct dentry *de = debugfs_create_file(name, mode, parent, data, fops);
541 * @parent: a pointer to the parent dentry for this file. This should be a
542 * directory dentry if set. If this parameter is NULL, then the
547 * This function will return a pointer to a dentry if it succeeds. This
556 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
558 struct dentry *dentry = start_creating(name, parent);
561 if (IS_ERR(dentry))
562 return dentry;
565 failed_creating(dentry);
569 inode = debugfs_get_inode(dentry->d_sb);
573 return failed_creating(dentry);
582 d_instantiate(dentry, inode);
583 inc_nlink(d_inode(dentry->d_parent));
584 fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
585 return end_creating(dentry);
592 * @parent: a pointer to the parent dentry for this file. This should be a
593 * directory dentry if set. If this parameter is NULL, then the
600 struct dentry *debugfs_create_automount(const char *name,
601 struct dentry *parent,
605 struct dentry *dentry = start_creating(name, parent);
609 if (IS_ERR(dentry))
610 return dentry;
614 failed_creating(dentry);
621 failed_creating(dentry);
626 inode = debugfs_get_inode(dentry->d_sb);
631 return failed_creating(dentry);
637 dentry->d_fsdata = fsd;
640 d_instantiate(dentry, inode);
641 inc_nlink(d_inode(dentry->d_parent));
642 fsnotify_mkdir(d_inode(dentry->d_parent), dentry);
643 return end_creating(dentry);
651 * @parent: a pointer to the parent dentry for this symbolic link. This
652 * should be a directory dentry if set. If this parameter is NULL,
661 * This function will return a pointer to a dentry if it succeeds. This
670 struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent,
673 struct dentry *dentry;
679 dentry = start_creating(name, parent);
680 if (IS_ERR(dentry)) {
682 return dentry;
685 inode = debugfs_get_inode(dentry->d_sb);
690 return failed_creating(dentry);
695 d_instantiate(dentry, inode);
696 return end_creating(dentry);
700 static void __debugfs_file_removed(struct dentry *dentry)
707 * debugfs_file_get() must see a dead dentry or we must see a
711 fsd = READ_ONCE(dentry->d_fsdata);
718 static void remove_one(struct dentry *victim)
727 * @dentry: a pointer to a the dentry of the directory to be removed. If this
738 void debugfs_remove(struct dentry *dentry)
740 if (IS_ERR_OR_NULL(dentry))
744 simple_recursive_removal(dentry, remove_one);
752 * @parent: a pointer to the parent dentry of the item.
758 void debugfs_lookup_and_remove(const char *name, struct dentry *parent)
760 struct dentry *dentry;
762 dentry = debugfs_lookup(name, parent);
763 if (!dentry)
766 debugfs_remove(dentry);
767 dput(dentry);
773 * @old_dir: a pointer to the parent dentry for the renamed object. This
774 * should be a directory dentry.
775 * @old_dentry: dentry of an object to be renamed.
776 * @new_dir: a pointer to the parent dentry where the object should be
777 * moved. This should be a directory dentry.
790 struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
791 struct dentry *new_dir, const char *new_name)
794 struct dentry *dentry = NULL, *trap;
812 dentry = lookup_one_len(new_name, new_dir, strlen(new_name));
814 if (IS_ERR(dentry) || dentry == trap || d_really_is_positive(dentry))
820 dentry, 0);
825 d_move(old_dentry, dentry);
831 dput(dentry);
834 if (dentry && !IS_ERR(dentry))
835 dput(dentry);
837 if (IS_ERR(dentry))
838 return dentry;