本文整理汇总了C++中d_lookup函数的典型用法代码示例。如果您正苦于以下问题:C++ d_lookup函数的具体用法?C++ d_lookup怎么用?C++ d_lookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_lookup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:mpalmer,项目名称:linux-2.6,代码行数:31,代码来源:dev-ioctl.c
示例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;
}
开发者ID:JBTech,项目名称:ralink_rt5350,代码行数:35,代码来源:dir.c
示例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;
}
开发者ID:mb3dot,项目名称:community-b3-kernel,代码行数:59,代码来源:readdir.c
示例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 */
}
开发者ID:BackupTheBerlios,项目名称:samqfs,代码行数:56,代码来源:client.c
示例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;
}
开发者ID:mikeberkelaar,项目名称:grhardened,代码行数:52,代码来源:readdir.c
示例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;
}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:50,代码来源:readdir.c
示例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;
}
开发者ID:mjduddin,项目名称:B14CKB1RD_kernel_m8,代码行数:48,代码来源:readdir.c
示例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;
}
开发者ID:foxsat-hdr,项目名称:linux-kernel,代码行数:47,代码来源:readdir.c
示例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;
}
开发者ID:fwmfee,项目名称:linux-legacy,代码行数:48,代码来源:readdir.c
示例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");
}
}
开发者ID:olebole,项目名称:iraf,代码行数:49,代码来源:decl.c
示例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);
}
}
开发者ID:vipiin,项目名称:dictionary,代码行数:20,代码来源:d_run.c
示例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);
}
开发者ID:nos1609,项目名称:Chrono_Kernel-1,代码行数:37,代码来源:proc_sysctl.c
示例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;
}
开发者ID:mpalmer,项目名称:linux-2.6,代码行数:40,代码来源:dev-ioctl.c
示例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;
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:36,代码来源:dir.c
示例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);
}
开发者ID:anchalagarwal08,项目名称:Wrapfs-Implementations,代码行数:80,代码来源:lookup.c
示例16: smb_fill_cache
/*
* Create dentry/inode for this file and add it to the dircache.
*/
int
smb_fill_cache(struct file *filp, void *dirent, filldir_t filldir,
struct smb_cache_control *ctrl, struct qstr *qname,
struct smb_fattr *entry)
{
struct dentry *newdent, *dentry = filp->f_path.dentry;
struct inode *newino, *inode = dentry->d_inode;
struct smb_cache_control ctl = *ctrl;
int valid = 0;
int hashed = 0;
ino_t ino = 0;
qname->hash = full_name_hash(qname->name, qname->len);
if (dentry->d_op && dentry->d_op->d_hash)
if (dentry->d_op->d_hash(dentry, qname) != 0)
goto end_advance;
newdent = d_lookup(dentry, qname);
if (!newdent) {
newdent = d_alloc(dentry, qname);
if (!newdent)
goto end_advance;
} else {
hashed = 1;
memcpy((char *) newdent->d_name.name, qname->name,
newdent->d_name.len);
}
if (!newdent->d_inode) {
smb_renew_times(newdent);
entry->f_ino = iunique(inode->i_sb, 2);
newino = smb_iget(inode->i_sb, entry);
if (newino) {
smb_new_dentry(newdent);
d_instantiate(newdent, newino);
if (!hashed)
d_rehash(newdent);
}
} else
smb_set_inode_attr(newdent->d_inode, entry);
if (newdent->d_inode) {
ino = newdent->d_inode->i_ino;
newdent->d_fsdata = (void *) ctl.fpos;
smb_new_dentry(newdent);
}
if (ctl.idx >= SMB_DIRCACHE_SIZE) {
if (ctl.page) {
kunmap(ctl.page);
SetPageUptodate(ctl.page);
unlock_page(ctl.page);
page_cache_release(ctl.page);
}
ctl.cache = NULL;
ctl.idx -= SMB_DIRCACHE_SIZE;
ctl.ofs += 1;
ctl.page = grab_cache_page(&inode->i_data, ctl.ofs);
if (ctl.page)
ctl.cache = kmap(ctl.page);
}
if (ctl.cache) {
ctl.cache->dentry[ctl.idx] = newdent;
valid = 1;
}
dput(newdent);
end_advance:
if (!valid)
ctl.valid = 0;
if (!ctl.filled && (ctl.fpos == filp->f_pos)) {
if (!ino)
ino = find_inode_number(dentry, qname);
if (!ino)
ino = iunique(inode->i_sb, 2);
ctl.filled = filldir(dirent, qname->name, qname->len,
filp->f_pos, ino, DT_UNKNOWN);
if (!ctl.filled)
filp->f_pos += 1;
}
ctl.fpos += 1;
ctl.idx += 1;
*ctrl = ctl;
return (ctl.valid || !ctl.filled);
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:90,代码来源:cache.c
示例17: fuse_direntplus_link
static int fuse_direntplus_link(struct file *file,
struct fuse_direntplus *direntplus,
u64 attr_version)
{
struct fuse_entry_out *o = &direntplus->entry_out;
struct fuse_dirent *dirent = &direntplus->dirent;
struct dentry *parent = file->f_path.dentry;
struct qstr name = QSTR_INIT(dirent->name, dirent->namelen);
struct dentry *dentry;
struct dentry *alias;
struct inode *dir = d_inode(parent);
struct fuse_conn *fc;
struct inode *inode;
DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
if (!o->nodeid) {
/*
* Unlike in the case of fuse_lookup, zero nodeid does not mean
* ENOENT. Instead, it only means the userspace filesystem did
* not want to return attributes/handle for this entry.
*
* So do nothing.
*/
return 0;
}
if (name.name[0] == '.') {
/*
* We could potentially refresh the attributes of the directory
* and its parent?
*/
if (name.len == 1)
return 0;
if (name.name[1] == '.' && name.len == 2)
return 0;
}
if (invalid_nodeid(o->nodeid))
return -EIO;
if (!fuse_valid_type(o->attr.mode))
return -EIO;
fc = get_fuse_conn(dir);
name.hash = full_name_hash(parent, name.name, name.len);
dentry = d_lookup(parent, &name);
if (!dentry) {
retry:
dentry = d_alloc_parallel(parent, &name, &wq);
if (IS_ERR(dentry))
return PTR_ERR(dentry);
}
if (!d_in_lookup(dentry)) {
struct fuse_inode *fi;
inode = d_inode(dentry);
if (!inode ||
get_node_id(inode) != o->nodeid ||
((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
d_invalidate(dentry);
dput(dentry);
goto retry;
}
if (is_bad_inode(inode)) {
dput(dentry);
return -EIO;
}
fi = get_fuse_inode(inode);
spin_lock(&fc->lock);
fi->nlookup++;
spin_unlock(&fc->lock);
forget_all_cached_acls(inode);
fuse_change_attributes(inode, &o->attr,
entry_attr_timeout(o),
attr_version);
/*
* The other branch comes via fuse_iget()
* which bumps nlookup inside
*/
} else {
inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
&o->attr, entry_attr_timeout(o),
attr_version);
if (!inode)
inode = ERR_PTR(-ENOMEM);
alias = d_splice_alias(inode, dentry);
d_lookup_done(dentry);
if (alias) {
dput(dentry);
dentry = alias;
}
if (IS_ERR(dentry))
return PTR_ERR(dentry);
}
if (fc->readdirplus_auto)
set_bit(FUSE_I_INIT_RDPLUS, &get_fuse_inode(inode)->state);
fuse_change_entry_timeout(dentry, o);
//.........这里部分代码省略.........
开发者ID:mkrufky,项目名称:linux,代码行数:101,代码来源:dir.c
示例18: get_fs
struct file *replayfs_open_filp_by_id(struct vfsmount *vfs,
struct replayfs_unique_id *id, loff_t version) {
struct inode *req_inode;
mm_segment_t old_fs;
struct inode *inode;
struct dentry *dentry;
struct file *new_filp;
struct dentry *new_dentry;
struct qstr new_str;
char *name;
old_fs = get_fs();
set_fs(KERNEL_DS);
debugk("%s %d: arguments ({%lld, %lld}, %lld)\n", __func__, __LINE__,
id->log_num, id->sys_num, version);
set_fs(old_fs);
/* Get the root's inode */
inode = vfs->mnt_sb->s_root->d_inode;
dentry = vfs->mnt_sb->s_root;
/* Open the new file */
/* Instantiate a dentry for this file */
/*
* NOTE: This dentry will only be used for this file, all other
* accesses will point to the current version...
*/
/* Need to fudge the dentry creation... give it a fake name */
/* Make a new qstr to hold the fudged name */
/* Put name on the heap, so it doesn't overflow the stack... */
debugk("%s %d: About to call kmalloc\n", __func__, __LINE__);
/*name = kmalloc(PAGE_SIZE, GFP_NOFS);*/
name = kmem_cache_alloc(replayfs_page_cache, GFP_NOFS);
debugk("%s %d: kmalloc done\n", __func__, __LINE__);
/* Now, append our prefix to the current name */
name[0] = '\0';
sprintf(name, "__%016llX_%016llX_%016llX", (unsigned long long)version,
(unsigned long long)id->log_num, (unsigned long long)id->sys_num);
new_str.len = strlen(name);
new_str.name = name;
new_str.hash = full_name_hash(new_str.name, new_str.len);
debugk("%s %d: new name is %s\n", __func__, __LINE__, new_str.name);
/* Give that name to the dentry */
/* See if the entry exists in the dentry cache */
new_dentry = d_lookup(dentry, &new_str);
debugk("%s %d: new dentry is %p\n", __func__, __LINE__, new_dentry);
if (new_dentry == NULL) {
debugk("%s %d: about to call d_alloc\n", __func__, __LINE__);
new_dentry = d_alloc(dentry, &new_str);
debugk("%s %d: dalloc'd new dentry %p\n", __func__, __LINE__, new_dentry);
if (new_dentry == NULL) {
/*kfree(name);*/
kmem_cache_free(replayfs_page_cache, name);
return ERR_PTR(-ENOMEM);
}
/* Now get the inode of this file */
debugk("%s %d: about to call replayfs_iget\n", __func__, __LINE__);
req_inode = replayfs_iget(inode->i_sb, id, version);
debugk("%s %d: done calling replayfs_iget\n", __func__, __LINE__);
if (req_inode == NULL) {
d_delete(new_dentry);
new_filp = ERR_PTR(-ENOMEM);
goto out;
}
inode_inc_link_count(req_inode);
inode_inc_link_count(inode);
debugk("%s %d: about to call d_add\n", __func__, __LINE__);
d_add(new_dentry, req_inode);
debugk("%s %d: added new dentry %p\n", __func__, __LINE__, new_dentry);
} else {
req_inode = new_dentry->d_inode;
}
/* We can free the memory used for naming now */
/*kfree(name);*/
kmem_cache_free(replayfs_page_cache, name);
/* Get our new file pointer */
debugk("%s %d: calling dentry_open\n", __func__, __LINE__);
new_filp = dentry_open(new_dentry, mntget(vfs), O_RDONLY);
debugk("%s %d: called dentry_open, new_filp is %p\n", __func__, __LINE__,
new_filp);
if (IS_ERR(new_filp)) {
d_delete(new_dentry);
goto out;
} else {
}
//.........这里部分代码省略.........
开发者ID:aywq2008,项目名称:omniplay,代码行数:101,代码来源:replayfs_fs.c
示例19: fuse_direntplus_link
static int fuse_direntplus_link(struct file *file,
struct fuse_direntplus *direntplus,
u64 attr_version)
{
int err;
struct fuse_entry_out *o = &direntplus->entry_out;
struct fuse_dirent *dirent = &direntplus->dirent;
struct dentry *parent = file->f_path.dentry;
struct qstr name = { .len = dirent->namelen, .name = dirent->name };
struct dentry *dentry;
struct dentry *alias;
struct inode *dir = parent->d_inode;
struct fuse_conn *fc;
struct inode *inode;
if (!o->nodeid) {
/*
* Unlike in the case of fuse_lookup, zero nodeid does not mean
* ENOENT. Instead, it only means the userspace filesystem did
* not want to return attributes/handle for this entry.
*
* So do nothing.
*/
return 0;
}
if (name.name[0] == '.') {
/*
* We could potentially refresh the attributes of the directory
* and its parent?
*/
if (name.len == 1)
return 0;
if (name.name[1] == '.' && name.len == 2)
return 0;
}
if (invalid_nodeid(o->nodeid))
return -EIO;
if (!fuse_valid_type(o->attr.mode))
return -EIO;
fc = get_fuse_conn(dir);
name.hash = full_name_hash(name.name, name.len);
dentry = d_lookup(parent, &name);
if (dentry) {
inode = dentry->d_inode;
if (!inode) {
d_drop(dentry);
} else if (get_node_id(inode) != o->nodeid ||
((o->attr.mode ^ inode->i_mode) & S_IFMT)) {
err = d_invalidate(dentry);
if (err)
goto out;
} else if (is_bad_inode(inode)) {
err = -EIO;
goto out;
} else {
struct fuse_inode *fi;
fi = get_fuse_inode(inode);
spin_lock(&fc->lock);
fi->nlookup++;
spin_unlock(&fc->lock);
fuse_change_attributes(inode, &o->attr,
entry_attr_timeout(o),
attr_version);
/*
* The other branch to 'found' comes via fuse_iget()
* which bumps nlookup inside
*/
goto found;
}
dput(dentry);
}
dentry = d_alloc(parent, &name);
err = -ENOMEM;
if (!dentry)
goto out;
dentry->d_op = &fuse_dentry_operations;
inode = fuse_iget(dir->i_sb, o->nodeid, o->generation,
&o->attr, entry_attr_timeout(o), attr_version);
if (!inode)
goto out;
alias = fuse_materialise_dentry(dentry, inode);
err = PTR_ERR(alias);
if (IS_ERR(alias))
goto out;
if (alias) {
dput(dentry);
dentry = alias;
}
found:
//.........这里部分代码省略.........
开发者ID:miurahr,项目名称:fuse-centos6-kernel-backport,代码行数:101,代码来源:dir.c
示例20: replayfs_ioctl
long replayfs_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg) {
struct inode *inode;
struct dentry *dentry;
dentry = filp->f_dentry;
inode = filp->f_dentry->d_inode;
debugk("In %s!\n", __func__);
debugk("%s %d: Cmd is %u, REPLAYFS_IOCTL_SET_VERSION is %u REPLAYFS_IOCTL_GET_VERSION is %u\n", __func__,
__LINE__, cmd, REPLAYFS_IOCTL_SET_VERSION, REPLAYFS_IOCTL_GET_VERSION);
switch (cmd) {
/* Opens a new fd to point to the requested version of the file */
case REPLAYFS_IOCTL_SET_VERSION:
do {
unsigned long long req_version;
long new_fd;
struct inode *req_inode;
debugk("%s %d: cmd is SET_VERSION\n", __func__, __LINE__);
if (copy_from_user(&req_version, (unsigned long long __user *)arg,
sizeof(unsigned long long))) {
return -EFAULT;
}
/* They requested a version > current... we can't do that! */
if (req_version >= replayfs_file_log_size(REPLAYFS_I(inode)->file_log)) {
return -EINVAL;
}
/* Open the new file */
new_fd = get_unused_fd();
if (new_fd >= 0) {
struct file *new_filp;
struct dentry *new_dentry;
struct qstr new_str;
char *name;
int oldname_len;
const char *oldname;
oldname = dentry->d_name.name;
oldname_len = dentry->d_name.len;
/* Instantiate a dentry for this file */
/*
* NOTE: This dentry will only be used for this file, all other
* accesses will point to the current version...
*/
/* Need to fudge the dentry creation... give it a fake name */
/* Make a new qstr to hold the fudged name */
/* Put name on the heap, so it doesn't overflow the stack... */
name = kmalloc(PAGE_SIZE, GFP_NOFS);
/* See if the current dentry is already a replayfs versioned file */
if (dentry->d_name.len > 17) {
if (!memcmp(dentry->d_name.name, "__replayfsvers", 14)) {
/*
* The name is already replayfs versioned... remove the version
* info
*/
int uscore_cnt;
int offs;
for (uscore_cnt = 0, offs=14; uscore_cnt < 2; offs++) {
BUG_ON(offs == dentry->d_name.len);
if (oldname[14] == '_') {
uscore_cnt++;
}
}
oldname_len -= offs;
oldname += offs;
}
}
/* Now, append our prefix to the current name */
name[0] = '\0';
sprintf(name, "__replayfsvers%llu__%*.s", req_version, oldname_len, oldname);
new_str.len = strlen(name);
new_str.name = name;
new_str.hash = full_name_hash(new_str.name, new_str.len);
debugk("%s %d: new name is %s", __func__, __LINE__, new_str.name);
/* Name formua is: __replayfsvers%version%__%filename% */
/* Give that name to the dentry */
/* See if the entry exists in the dentry cache */
new_dentry = d_lookup(dentry->d_parent, &new_str);
if (new_dentry == NULL) {
new_dentry = d_alloc(dentry->d_parent, &new_str);
if (new_dentry == NULL) {
put_unused_fd(new_fd);
kfree(name);
//.........这里部分代码省略.........
开发者ID:aywq2008,项目名称:omniplay,代码行数:101,代码来源:replayfs_fs.c
注:本文中的d_lookup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论