本文整理汇总了C++中d_lookup函数的典型用法代码示例。如果您正苦于以下问题:C++ d_lookup函数的具体用法?C++ d_lookup怎么用?C++ d_lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_lookup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: autofs_dev_ioctl_find_sbi_type
/*
* Walk down the mount stack looking for an autofs mount that
* has the requested mount type (ie. indirect, direct or offset).
*/
static int autofs_dev_ioctl_find_sbi_type(struct nameidata *nd, unsigned int type)
{
struct dentry *dentry;
struct autofs_info *ino;
unsigned int err;
err = -ENOENT;
/* Lookup the dentry name at the base of our mount point */
dentry = d_lookup(nd->path.dentry, &nd->last);
if (!dentry)
goto out;
dput(nd->path.dentry);
nd->path.dentry = dentry;
/* And follow the mount stack looking for our autofs mount */
while (follow_down(&nd->path.mnt, &nd->path.dentry)) {
ino = autofs4_dentry_ino(nd->path.dentry);
if (ino && ino->sbi->type & type) {
err = 0;
break;
}
}
out:
return err;
}
示例2: full_name_hash
/*
* Lookup or create a dentry from within the filesystem.
*
* We need to use this instead of lookup_dentry, as the
* directory semaphore lock is already held.
*/
struct dentry *umsdos_lookup_dentry(struct dentry *parent, char *name, int len,
int real)
{
struct dentry *result, *dentry;
struct qstr qstr;
qstr.name = name;
qstr.len = len;
qstr.hash = full_name_hash(name, len);
result = d_lookup(parent, &qstr);
if (!result) {
result = ERR_PTR(-ENOMEM);
dentry = d_alloc(parent, &qstr);
if (dentry) {
result = real ?
UMSDOS_rlookup(parent->d_inode, dentry) :
UMSDOS_lookup(parent->d_inode, dentry);
if (result)
goto out_fail;
return dentry;
}
}
out:
return result;
out_fail:
dput(dentry);
goto out;
}
示例3: cifs_readdir_lookup
/*
* Find the dentry that matches "name". If there isn't one, create one. If it's
* a negative dentry or the uniqueid changed, then drop it and recreate it.
*/
static struct dentry *
cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
struct cifs_fattr *fattr)
{
struct dentry *dentry, *alias;
struct inode *inode;
struct super_block *sb = parent->d_inode->i_sb;
cFYI(1, "For %s", name->name);
if (parent->d_op && parent->d_op->d_hash)
parent->d_op->d_hash(parent, parent->d_inode, name);
else
name->hash = full_name_hash(name->name, name->len);
dentry = d_lookup(parent, name);
if (dentry) {
inode = dentry->d_inode;
/* update inode in place if i_ino didn't change */
if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
cifs_fattr_to_inode(inode, fattr);
return dentry;
}
d_drop(dentry);
dput(dentry);
}
/*
* If we know that the inode will need to be revalidated immediately,
* then don't create a new dentry for it. We'll end up doing an on
* the wire call either way and this spares us an invalidation.
*/
if (fattr->cf_flags & CIFS_FATTR_NEED_REVAL)
return NULL;
dentry = d_alloc(parent, name);
if (dentry == NULL)
return NULL;
inode = cifs_iget(sb, fattr);
if (!inode) {
dput(dentry);
return NULL;
}
alias = d_materialise_unique(dentry, inode);
if (alias != NULL) {
dput(dentry);
if (IS_ERR(alias))
return NULL;
dentry = alias;
}
return dentry;
}
示例4: samqfs_notify_dnlc_remove
/*
* ------ samqfs_notify_dnlc_remove -
* Look for a dnlc/dcache entry of pip/comp
* and delete it from the dnlc/dcache.
*/
void
samqfs_notify_dnlc_remove(
sam_node_t *pip, /* parent inode */
char *comp) /* name to be deleted from the dcache */
{
#ifdef sun
(void) dnlc_remove(SAM_ITOV(pip), comp);
#endif /* sun */
#ifdef linux
struct inode *pli;
int length;
struct dentry *dir, *de;
struct qstr qstr;
if (pip == NULL) {
return;
}
if (comp == NULL) {
return;
}
pli = SAM_SITOLI(pip);
length = strlen(comp);
if ((length == 0) || (length > NAME_MAX)) {
return;
}
/*
* Find the dcache entry of the parent.
*/
dir = d_find_alias(pli);
if (dir) {
/*
* Find the dcache entry of the component.
*/
qstr.name = comp;
qstr.len = length;
qstr.hash = rfs_full_name_hash(comp, length);
de = d_lookup(dir, &qstr);
if (de) {
rfs_d_drop(de);
dput(de);
}
dput(dir);
}
#endif /* linux */
}
示例5: construct_dentry
/* Might check in the future if inode number changed so we can rehash inode */
static int construct_dentry(struct qstr *qstring, struct file *file,
struct inode **ptmp_inode, struct dentry **pnew_dentry)
{
struct dentry *tmp_dentry;
struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon;
int rc = 0;
cFYI(1, ("For %s", qstring->name));
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
pTcon = cifs_sb->tcon;
qstring->hash = full_name_hash(qstring->name, qstring->len);
tmp_dentry = d_lookup(file->f_path.dentry, qstring);
if (tmp_dentry) {
cFYI(0, ("existing dentry with inode 0x%p",
tmp_dentry->d_inode));
*ptmp_inode = tmp_dentry->d_inode;
/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
if (*ptmp_inode == NULL) {
*ptmp_inode = new_inode(file->f_path.dentry->d_sb);
if (*ptmp_inode == NULL)
return rc;
rc = 1;
}
if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
(*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
} else {
tmp_dentry = d_alloc(file->f_path.dentry, qstring);
if (tmp_dentry == NULL) {
cERROR(1, ("Failed allocating dentry"));
*ptmp_inode = NULL;
return rc;
}
*ptmp_inode = new_inode(file->f_path.dentry->d_sb);
if (pTcon->nocase)
tmp_dentry->d_op = &cifs_ci_dentry_ops;
else
tmp_dentry->d_op = &cifs_dentry_ops;
if (*ptmp_inode == NULL)
return rc;
if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
(*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
rc = 2;
}
tmp_dentry->d_time = jiffies;
*pnew_dentry = tmp_dentry;
return rc;
}
示例6: construct_dentry
/* Might check in the future if inode number changed so we can rehash inode */
static int
construct_dentry(struct qstr *qstring, struct file *file,
struct inode **ptmp_inode, struct dentry **pnew_dentry,
__u64 *inum)
{
struct dentry *tmp_dentry = NULL;
struct super_block *sb = file->f_path.dentry->d_sb;
int rc = 0;
cFYI(1, ("For %s", qstring->name));
qstring->hash = full_name_hash(qstring->name, qstring->len);
tmp_dentry = d_lookup(file->f_path.dentry, qstring);
if (tmp_dentry) {
/* BB: overwrite old name? i.e. tmp_dentry->d_name and
* tmp_dentry->d_name.len??
*/
cFYI(0, ("existing dentry with inode 0x%p",
tmp_dentry->d_inode));
*ptmp_inode = tmp_dentry->d_inode;
if (*ptmp_inode == NULL) {
*ptmp_inode = cifs_new_inode(sb, inum);
if (*ptmp_inode == NULL)
return rc;
rc = 1;
}
} else {
tmp_dentry = d_alloc(file->f_path.dentry, qstring);
if (tmp_dentry == NULL) {
cERROR(1, ("Failed allocating dentry"));
*ptmp_inode = NULL;
return rc;
}
if (CIFS_SB(sb)->tcon->nocase)
tmp_dentry->d_op = &cifs_ci_dentry_ops;
else
tmp_dentry->d_op = &cifs_dentry_ops;
*ptmp_inode = cifs_new_inode(sb, inum);
if (*ptmp_inode == NULL)
return rc;
rc = 2;
}
tmp_dentry->d_time = jiffies;
*pnew_dentry = tmp_dentry;
return rc;
}
示例7: cifs_readdir_lookup
static struct dentry *
cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
struct cifs_fattr *fattr)
{
struct dentry *dentry, *alias;
struct inode *inode;
struct super_block *sb = parent->d_inode->i_sb;
cFYI(1, "For %s", name->name);
if (parent->d_op && parent->d_op->d_hash)
parent->d_op->d_hash(parent, parent->d_inode, name);
else
name->hash = full_name_hash(name->name, name->len);
dentry = d_lookup(parent, name);
if (dentry) {
inode = dentry->d_inode;
/* update inode in place if i_ino didn't change */
if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) {
cifs_fattr_to_inode(inode, fattr);
return dentry;
}
d_drop(dentry);
dput(dentry);
}
dentry = d_alloc(parent, name);
if (dentry == NULL)
return NULL;
inode = cifs_iget(sb, fattr);
if (!inode) {
dput(dentry);
return NULL;
}
alias = d_materialise_unique(dentry, inode);
if (alias != NULL) {
dput(dentry);
if (IS_ERR(alias))
return NULL;
dentry = alias;
}
return dentry;
}
示例8: construct_dentry
/* Might check in the future if inode number changed so we can rehash inode */
static int construct_dentry(struct qstr *qstring, struct file *file,
struct inode **ptmp_inode, struct dentry **pnew_dentry)
{
struct dentry *tmp_dentry;
struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon;
int rc = 0;
cFYI(1, ("For %s", qstring->name));
cifs_sb = CIFS_SB(file->f_dentry->d_sb);
pTcon = cifs_sb->tcon;
qstring->hash = full_name_hash(qstring->name, qstring->len);
tmp_dentry = d_lookup(file->f_dentry, qstring);
if (tmp_dentry) {
cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode));
*ptmp_inode = tmp_dentry->d_inode;
/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
if(*ptmp_inode == NULL) {
*ptmp_inode = new_inode(file->f_dentry->d_sb);
if(*ptmp_inode == NULL)
return rc;
rc = 1;
d_instantiate(tmp_dentry, *ptmp_inode);
}
} else {
tmp_dentry = d_alloc(file->f_dentry, qstring);
if(tmp_dentry == NULL) {
cERROR(1,("Failed allocating dentry"));
*ptmp_inode = NULL;
return rc;
}
*ptmp_inode = new_inode(file->f_dentry->d_sb);
tmp_dentry->d_op = &cifs_dentry_ops;
if(*ptmp_inode == NULL)
return rc;
rc = 1;
d_instantiate(tmp_dentry, *ptmp_inode);
d_rehash(tmp_dentry);
}
tmp_dentry->d_time = jiffies;
*pnew_dentry = tmp_dentry;
return rc;
}
示例9: cifs_readdir_lookup
/*
* Find the dentry that matches "name". If there isn't one, create one. If it's
* a negative dentry or the uniqueid changed, then drop it and recreate it.
*/
static struct dentry *
cifs_readdir_lookup(struct dentry *parent, struct qstr *name,
struct cifs_fattr *fattr)
{
struct dentry *dentry, *alias;
struct inode *inode;
struct super_block *sb = parent->d_inode->i_sb;
cFYI(1, ("For %s", name->name));
dentry = d_lookup(parent, name);
if (dentry) {
/* FIXME: check for inode number changes? */
if (dentry->d_inode != NULL)
return dentry;
d_drop(dentry);
dput(dentry);
}
dentry = d_alloc(parent, name);
if (dentry == NULL)
return NULL;
inode = cifs_iget(sb, fattr);
if (!inode) {
dput(dentry);
return NULL;
}
if (CIFS_SB(sb)->tcon->nocase)
dentry->d_op = &cifs_ci_dentry_ops;
else
dentry->d_op = &cifs_dentry_ops;
alias = d_materialise_unique(dentry, inode);
if (alias != NULL) {
dput(dentry);
if (IS_ERR(alias))
return NULL;
dentry = alias;
}
return dentry;
}
示例10: d_newproc
/* D_NEWPROC -- Process a procedure declaration. The name of the procedure
* is passed as the single argument. The input stream is left positioned
* with the ( of the argument list as the next token (if present). INPUT is
* called repeatedly to read the remainder of the declaration, which may span
* several lines. The symbol table is cleared whenever a new procedure
* declaration is started.
*/
void
d_newproc (
char *name, /* procedure name */
int dtype /* procedure type (0 if subr) */
)
{
register int token;
char tokstr[SZ_TOKEN+1];
strncpy (procname, name, SZ_FNAME);
proctype = dtype;
nextch = sbuf;
nsym = 0;
/* Check for null argument list. */
if (d_gettok(tokstr,SZ_TOKEN) != '(')
return;
/* Process the argument list.
*/
while ((token = d_gettok(tokstr,SZ_TOKEN)) != ')') {
if (isalpha(token)) {
/* Enter argument name into the symbol table.
*/
if (d_lookup (tokstr) != NULL) {
char lbuf[200];
sprintf (lbuf, "%s.%s multiply declared",
procname, tokstr);
xpp_warn (lbuf);
} else
d_enter (tokstr, UNDECL, S_ARGUMENT);
} else if (token == '\n') {
linenum[istkptr]++;
continue;
} else if (token == ',') {
continue;
} else
error (XPP_SYNTAX, "bad syntax in procedure argument list");
}
}
示例11: main
int main(int argc, char ** argv)
{
int i;
char word[MAX_WORD_SIZE+1];
char answer[MAX_DESC_SIZE+1];
d_initialise();
for (i=1; i<argc; i++)
d_read_from_file(argv[i]);
scanf("%s",word);
while(word[0] != '.') {
if (d_lookup(word,answer))
printf("%s:\t%s\n", word, answer);
else
printf("%s:\t%s\n", word, "Not in dictionary");
scanf("%s",word);
}
}
示例12: proc_sys_fill_cache
static int proc_sys_fill_cache(struct file *filp, void *dirent,
filldir_t filldir,
struct ctl_table_header *head,
struct ctl_table *table)
{
struct dentry *child, *dir = filp->f_path.dentry;
struct inode *inode;
struct qstr qname;
ino_t ino = 0;
unsigned type = DT_UNKNOWN;
qname.name = table->procname;
qname.len = strlen(table->procname);
qname.hash = full_name_hash(qname.name, qname.len);
child = d_lookup(dir, &qname);
if (!child) {
child = d_alloc(dir, &qname);
if (child) {
inode = proc_sys_make_inode(dir->d_sb, head, table);
if (!inode) {
dput(child);
return -ENOMEM;
} else {
d_set_d_op(child, &proc_sys_dentry_operations);
d_add(child, inode);
}
} else {
return -ENOMEM;
}
}
inode = child->d_inode;
ino = inode->i_ino;
type = inode->i_mode >> 12;
dput(child);
return !!filldir(dirent, qname.name, qname.len, filp->f_pos, ino, type);
}
示例13: autofs_dev_ioctl_find_super
/*
* Walk down the mount stack looking for an autofs mount that
* has the requested device number (aka. new_encode_dev(sb->s_dev).
*/
static int autofs_dev_ioctl_find_super(struct nameidata *nd, dev_t devno)
{
struct dentry *dentry;
struct inode *inode;
struct super_block *sb;
dev_t s_dev;
unsigned int err;
err = -ENOENT;
/* Lookup the dentry name at the base of our mount point */
dentry = d_lookup(nd->path.dentry, &nd->last);
if (!dentry)
goto out;
dput(nd->path.dentry);
nd->path.dentry = dentry;
/* And follow the mount stack looking for our autofs mount */
while (follow_down(&nd->path.mnt, &nd->path.dentry)) {
inode = nd->path.dentry->d_inode;
if (!inode)
break;
sb = inode->i_sb;
s_dev = new_encode_dev(sb->s_dev);
if (devno == s_dev) {
if (sb->s_magic == AUTOFS_SUPER_MAGIC) {
err = 0;
break;
}
}
}
out:
return err;
}
示例14: fuse_reverse_inval_entry
int fuse_reverse_inval_entry(struct super_block *sb, u64 parent_nodeid,
struct qstr *name)
{
int err = -ENOTDIR;
struct inode *parent;
struct dentry *dir;
struct dentry *entry;
parent = ilookup5(sb, parent_nodeid, fuse_inode_eq, &parent_nodeid);
if (!parent)
return -ENOENT;
mutex_lock(&parent->i_mutex);
if (!S_ISDIR(parent->i_mode))
goto unlock;
err = -ENOENT;
dir = d_find_alias(parent);
if (!dir)
goto unlock;
entry = d_lookup(dir, name);
dput(dir);
if (!entry)
goto unlock;
fuse_invalidate_attr(parent);
fuse_invalidate_entry(entry);
dput(entry);
err = 0;
unlock:
mutex_unlock(&parent->i_mutex);
iput(parent);
return err;
}
示例15: d_set_d_op
/*
* Main driver function for wrapfs's lookup.
*
* Returns: NULL (ok), ERR_PTR if an error occurred.
* Fills in lower_parent_path with <dentry,mnt> on success.
*/
static struct dentry *__wrapfs_lookup(struct dentry *dentry, int flags,
struct path *lower_parent_path)
{
int err = 0;
struct vfsmount *lower_dir_mnt;
struct dentry *lower_dir_dentry = NULL;
struct dentry *lower_dentry;
const char *name;
struct path lower_path;
struct qstr this;
/* must initialize dentry operations */
d_set_d_op(dentry, &wrapfs_dops);
if (IS_ROOT(dentry))
goto out;
name = dentry->d_name.name;
/* now start the actual lookup procedure */
lower_dir_dentry = lower_parent_path->dentry;
lower_dir_mnt = lower_parent_path->mnt;
/* Use vfs_path_lookup to check if the dentry exists or not */
err = vfs_path_lookup(lower_dir_dentry, lower_dir_mnt, name, 0,
&lower_path);
/* no error: handle positive dentries */
if (!err) {
wrapfs_set_lower_path(dentry, &lower_path);
err = wrapfs_interpose(dentry, dentry->d_sb, &lower_path);
if (err) /* path_put underlying path on error */
wrapfs_put_reset_lower_path(dentry);
goto out;
}
/*
* We don't consider ENOENT an error, and we want to return a
* negative dentry.
*/
if (err && err != -ENOENT)
goto out;
/* instatiate a new negative dentry */
this.name = name;
this.len = strlen(name);
this.hash = full_name_hash(this.name, this.len);
lower_dentry = d_lookup(lower_dir_dentry, &this);
if (lower_dentry)
goto setup_lower;
lower_dentry = d_alloc(lower_dir_dentry, &this);
if (!lower_dentry) {
err = -ENOMEM;
goto out;
}
d_add(lower_dentry, NULL); /* instantiate and hash */
setup_lower:
lower_path.dentry = lower_dentry;
lower_path.mnt = mntget(lower_dir_mnt);
wrapfs_set_lower_path(dentry, &lower_path);
/*
* If the intent is to create a file, then don't return an error, so
* the VFS will continue the process of making this negative dentry
* into a positive one.
*/
if (flags & (LOOKUP_CREATE|LOOKUP_RENAME_TARGET))
err = 0;
out:
return ERR_PTR(err);
}