本文整理汇总了C++中d_unhashed函数的典型用法代码示例。如果您正苦于以下问题:C++ d_unhashed函数的具体用法?C++ d_unhashed怎么用?C++ d_unhashed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_unhashed函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: v9fs_dentry2v9ses
static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
kuid_t uid, int any)
{
struct dentry *ds;
const unsigned char **wnames, *uname;
int i, n, l, clone, access;
struct v9fs_session_info *v9ses;
struct p9_fid *fid, *old_fid = NULL;
v9ses = v9fs_dentry2v9ses(dentry);
access = v9ses->flags & V9FS_ACCESS_MASK;
fid = v9fs_fid_find(dentry, uid, any);
if (fid)
return fid;
/*
* we don't have a matching fid. To do a TWALK we need
* parent fid. We need to prevent rename when we want to
* look at the parent.
*/
down_read(&v9ses->rename_sem);
ds = dentry->d_parent;
fid = v9fs_fid_find(ds, uid, any);
if (fid) {
/* Found the parent fid do a lookup with that */
fid = p9_client_walk(fid, 1, &dentry->d_name.name, 1);
goto fid_out;
}
up_read(&v9ses->rename_sem);
/* start from the root and try to do a lookup */
fid = v9fs_fid_find(dentry->d_sb->s_root, uid, any);
if (!fid) {
/* the user is not attached to the fs yet */
if (access == V9FS_ACCESS_SINGLE)
return ERR_PTR(-EPERM);
if (v9fs_proto_dotu(v9ses) || v9fs_proto_dotl(v9ses))
uname = NULL;
else
uname = v9ses->uname;
fid = p9_client_attach(v9ses->clnt, NULL, uname, uid,
v9ses->aname);
if (IS_ERR(fid))
return fid;
v9fs_fid_add(dentry->d_sb->s_root, fid);
}
/* If we are root ourself just return that */
if (dentry->d_sb->s_root == dentry)
return fid;
/*
* Do a multipath walk with attached root.
* When walking parent we need to make sure we
* don't have a parallel rename happening
*/
down_read(&v9ses->rename_sem);
n = build_path_from_dentry(v9ses, dentry, &wnames);
if (n < 0) {
fid = ERR_PTR(n);
goto err_out;
}
clone = 1;
i = 0;
while (i < n) {
l = min(n - i, P9_MAXWELEM);
/*
* We need to hold rename lock when doing a multipath
* walk to ensure none of the patch component change
*/
fid = p9_client_walk(fid, l, &wnames[i], clone);
if (IS_ERR(fid)) {
if (old_fid) {
/*
* If we fail, clunk fid which are mapping
* to path component and not the last component
* of the path.
*/
p9_client_clunk(old_fid);
}
kfree(wnames);
goto err_out;
}
old_fid = fid;
i += l;
clone = 0;
}
kfree(wnames);
fid_out:
if (!IS_ERR(fid)) {
spin_lock(&dentry->d_lock);
if (d_unhashed(dentry)) {
spin_unlock(&dentry->d_lock);
p9_client_clunk(fid);
fid = ERR_PTR(-ENOENT);
} else {
__add_fid(dentry, fid);
spin_unlock(&dentry->d_lock);
}
}
//.........这里部分代码省略.........
开发者ID:BWhitten,项目名称:linux-stable,代码行数:101,代码来源:fid.c
示例2: cifs_atomic_open
int
cifs_atomic_open(struct inode *inode, struct dentry *direntry,
struct file *file, unsigned oflags, umode_t mode,
int *opened)
{
int rc;
unsigned int xid;
struct tcon_link *tlink;
struct cifs_tcon *tcon;
struct TCP_Server_Info *server;
struct cifs_fid fid;
struct cifs_pending_open open;
__u32 oplock;
struct cifsFileInfo *file_info;
/*
* Posix open is only called (at lookup time) for file create now. For
* opens (rather than creates), because we do not know if it is a file
* or directory yet, and current Samba no longer allows us to do posix
* open on dirs, we could end up wasting an open call on what turns out
* to be a dir. For file opens, we wait to call posix open till
* cifs_open. It could be added to atomic_open in the future but the
* performance tradeoff of the extra network request when EISDIR or
* EACCES is returned would have to be weighed against the 50% reduction
* in network traffic in the other paths.
*/
if (!(oflags & O_CREAT)) {
struct dentry *res;
/*
* Check for hashed negative dentry. We have already revalidated
* the dentry and it is fine. No need to perform another lookup.
*/
if (!d_unhashed(direntry))
return -ENOENT;
res = cifs_lookup(inode, direntry, 0);
if (IS_ERR(res))
return PTR_ERR(res);
return finish_no_open(file, res);
}
rc = check_name(direntry);
if (rc)
return rc;
xid = get_xid();
cifs_dbg(FYI, "parent inode = 0x%p name is: %s and dentry = 0x%p\n",
inode, direntry->d_name.name, direntry);
tlink = cifs_sb_tlink(CIFS_SB(inode->i_sb));
if (IS_ERR(tlink)) {
rc = PTR_ERR(tlink);
goto out_free_xid;
}
tcon = tlink_tcon(tlink);
server = tcon->ses->server;
if (server->ops->new_lease_key)
server->ops->new_lease_key(&fid);
cifs_add_pending_open(&fid, tlink, &open);
rc = cifs_do_create(inode, direntry, xid, tlink, oflags, mode,
&oplock, &fid, opened);
if (rc) {
cifs_del_pending_open(&open);
goto out;
}
rc = finish_open(file, direntry, generic_file_open, opened);
if (rc) {
if (server->ops->close)
server->ops->close(xid, tcon, &fid);
cifs_del_pending_open(&open);
goto out;
}
file_info = cifs_new_fileinfo(&fid, file, tlink, oplock);
if (file_info == NULL) {
if (server->ops->close)
server->ops->close(xid, tcon, &fid);
cifs_del_pending_open(&open);
fput(file);
rc = -ENOMEM;
}
out:
cifs_put_tlink(tlink);
out_free_xid:
free_xid(xid);
return rc;
}
开发者ID:AICP,项目名称:kernel_moto_shamu,代码行数:97,代码来源:dir.c
示例3: hypfs_positive
static inline int hypfs_positive(struct dentry *dentry)
{
return dentry->d_inode && !d_unhashed(dentry);
}
开发者ID:alexey6600,项目名称:M8_Sense_7.00,代码行数:4,代码来源:inode.c
示例4: aufs_rename
int aufs_rename(struct inode *_src_dir, struct dentry *_src_dentry,
struct inode *_dst_dir, struct dentry *_dst_dentry)
{
int err, flags;
/* reduce stack space */
struct au_ren_args *a;
AuDbg("%.*s, %.*s\n", AuDLNPair(_src_dentry), AuDLNPair(_dst_dentry));
IMustLock(_src_dir);
IMustLock(_dst_dir);
err = -ENOMEM;
BUILD_BUG_ON(sizeof(*a) > PAGE_SIZE);
a = kzalloc(sizeof(*a), GFP_NOFS);
if (unlikely(!a))
goto out;
a->src_dir = _src_dir;
a->src_dentry = _src_dentry;
a->src_inode = a->src_dentry->d_inode;
a->src_parent = a->src_dentry->d_parent; /* dir inode is locked */
a->dst_dir = _dst_dir;
a->dst_dentry = _dst_dentry;
a->dst_inode = a->dst_dentry->d_inode;
a->dst_parent = a->dst_dentry->d_parent; /* dir inode is locked */
if (a->dst_inode) {
IMustLock(a->dst_inode);
au_igrab(a->dst_inode);
}
err = -ENOTDIR;
flags = AuLock_FLUSH | AuLock_NOPLM | AuLock_GEN;
if (S_ISDIR(a->src_inode->i_mode)) {
au_fset_ren(a->flags, ISDIR);
if (unlikely(a->dst_inode && !S_ISDIR(a->dst_inode->i_mode)))
goto out_free;
err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry,
AuLock_DIR | flags);
} else
err = aufs_read_and_write_lock2(a->dst_dentry, a->src_dentry,
flags);
if (unlikely(err))
goto out_free;
err = au_d_hashed_positive(a->src_dentry);
if (unlikely(err))
goto out_unlock;
err = -ENOENT;
if (a->dst_inode) {
/*
* If it is a dir, VFS unhash dst_dentry before this
* function. It means we cannot rely upon d_unhashed().
*/
if (unlikely(!a->dst_inode->i_nlink))
goto out_unlock;
if (!S_ISDIR(a->dst_inode->i_mode)) {
err = au_d_hashed_positive(a->dst_dentry);
if (unlikely(err))
goto out_unlock;
} else if (unlikely(IS_DEADDIR(a->dst_inode)))
goto out_unlock;
} else if (unlikely(d_unhashed(a->dst_dentry)))
goto out_unlock;
au_fset_ren(a->flags, ISSAMEDIR); /* temporary */
di_write_lock_parent(a->dst_parent);
/* which branch we process */
err = au_ren_wbr(a);
if (unlikely(err < 0))
goto out_parent;
a->br = au_sbr(a->dst_dentry->d_sb, a->btgt);
a->h_path.mnt = a->br->br_mnt;
/* are they available to be renamed */
err = au_ren_may_dir(a);
if (unlikely(err))
goto out_children;
/* prepare the writable parent dir on the same branch */
if (a->dst_bstart == a->btgt) {
au_fset_ren(a->flags, WHDST);
} else {
err = au_cpup_dirs(a->dst_dentry, a->btgt);
if (unlikely(err))
goto out_children;
}
if (a->src_dir != a->dst_dir) {
/*
* this temporary unlock is safe,
* because both dir->i_mutex are locked.
*/
di_write_unlock(a->dst_parent);
di_write_lock_parent(a->src_parent);
err = au_wr_dir_need_wh(a->src_dentry,
au_ftest_ren(a->flags, ISDIR),
&a->btgt);
di_write_unlock(a->src_parent);
di_write_lock2_parent(a->src_parent, a->dst_parent, /*isdir*/1);
//.........这里部分代码省略.........
开发者ID:CyanogenModXT720,项目名称:xt720_modules_eclair,代码行数:101,代码来源:i_op_ren.c
示例5: sdcardfskk_open
static int sdcardfskk_open(struct inode *inode, struct file *file)
{
int err = 0;
struct file *lower_file = NULL;
struct path lower_path;
struct dentry *dentry = file->f_path.dentry;
struct dentry *parent = dget_parent(dentry);
struct sdcardfskk_sb_info *sbi = SDCARDFSKK_SB(dentry->d_sb);
const struct cred *saved_cred = NULL;
int has_rw;
/* don't open unhashed/deleted files */
if (d_unhashed(dentry)) {
err = -ENOENT;
goto out_err;
}
has_rw = get_caller_has_rw_locked_kitkat(sbi->pkgl_id, sbi->options.derive);
if(!check_caller_access_to_name_kitkat(parent->d_inode, dentry->d_name.name,
sbi->options.derive,
open_flags_to_access_mode_kitkat(file->f_flags), has_rw)) {
printk(KERN_INFO "%s: need to check the caller's gid in packages.list\n"
" dentry: %s, task:%s\n",
__func__, dentry->d_name.name, current->comm);
err = -EACCES;
goto out_err;
}
/* save current_cred and override it */
OVERRIDE_CRED(sbi, saved_cred);
file->private_data =
kzalloc(sizeof(struct sdcardfskk_file_info), GFP_KERNEL);
if (!SDCARDFSKK_F(file)) {
err = -ENOMEM;
goto out_revert_cred;
}
/* open lower object and link sdcardfskk's file struct to lower's */
sdcardfskk_get_lower_path(file->f_path.dentry, &lower_path);
lower_file = dentry_open(lower_path.dentry, lower_path.mnt,
file->f_flags, current_cred());
if (IS_ERR(lower_file)) {
err = PTR_ERR(lower_file);
lower_file = sdcardfskk_lower_file(file);
if (lower_file) {
sdcardfskk_set_lower_file(file, NULL);
fput(lower_file); /* fput calls dput for lower_dentry */
}
} else {
sdcardfskk_set_lower_file(file, lower_file);
}
if (err)
kfree(SDCARDFSKK_F(file));
else {
mutex_lock(&inode->i_mutex);
sdcardfskk_copy_inode_attr(inode, sdcardfskk_lower_inode(inode));
fix_derived_permission(inode);
mutex_unlock(&inode->i_mutex);
}
out_revert_cred:
REVERT_CRED(saved_cred);
out_err:
dput(parent);
return err;
}
开发者ID:sms200207,项目名称:arter97-kernel-unofficial,代码行数:69,代码来源:file.c
示例6: au_refresh_dentry
int au_refresh_dentry(struct dentry *dentry, struct dentry *parent)
{
int err, ebrange;
unsigned int sigen;
struct au_dinfo *dinfo, *tmp;
struct super_block *sb;
struct inode *inode;
DiMustWriteLock(dentry);
AuDebugOn(IS_ROOT(dentry));
AuDebugOn(!parent->d_inode);
sb = dentry->d_sb;
inode = dentry->d_inode;
sigen = au_sigen(sb);
err = au_digen_test(parent, sigen);
if (unlikely(err))
goto out;
dinfo = au_di(dentry);
err = au_di_realloc(dinfo, au_sbend(sb) + 1);
if (unlikely(err))
goto out;
ebrange = au_dbrange_test(dentry);
if (!ebrange)
ebrange = au_do_refresh_hdentry(dentry, parent);
if (d_unhashed(dentry) || ebrange) {
AuDebugOn(au_dbstart(dentry) < 0 && au_dbend(dentry) >= 0);
if (inode)
err = au_refresh_hinode_self(inode);
au_dbg_verify_dinode(dentry);
if (!err)
goto out_dgen; /* success */
goto out;
}
/* temporary dinfo */
AuDbgDentry(dentry);
err = -ENOMEM;
tmp = au_di_alloc(sb, AuLsc_DI_TMP);
if (unlikely(!tmp))
goto out;
au_di_swap(tmp, dinfo);
/* returns the number of positive dentries */
/*
* if current working dir is removed, it returns an error.
* but the dentry is legal.
*/
err = au_lkup_dentry(dentry, /*bstart*/0, /*type*/0, /*nd*/NULL);
AuDbgDentry(dentry);
au_di_swap(tmp, dinfo);
if (err == -ENOENT)
err = 0;
if (err >= 0) {
/* compare/refresh by dinfo */
AuDbgDentry(dentry);
err = au_refresh_by_dinfo(dentry, dinfo, tmp);
au_dbg_verify_dinode(dentry);
AuTraceErr(err);
}
au_rw_write_unlock(&tmp->di_rwsem);
au_di_free(tmp);
if (unlikely(err))
goto out;
out_dgen:
au_update_digen(dentry);
out:
if (unlikely(err && !(dentry->d_flags & DCACHE_NFSFS_RENAMED))) {
AuIOErr("failed refreshing %.*s, %d\n",
AuDLNPair(dentry), err);
AuDbgDentry(dentry);
}
AuTraceErr(err);
return err;
}
开发者ID:marcero,项目名称:ab73kernel-Hannspad-2632,代码行数:77,代码来源:dentry.c
示例7: DPRINTK
static struct dentry *autofs_root_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
{
struct autofs_sb_info *sbi;
int oz_mode;
DPRINTK(("autofs_root_lookup: name = "));
lock_kernel();
autofs_say(dentry->d_name.name,dentry->d_name.len);
if (dentry->d_name.len > NAME_MAX) {
unlock_kernel();
return ERR_PTR(-ENAMETOOLONG);/* File name too long to exist */
}
sbi = autofs_sbi(dir->i_sb);
oz_mode = autofs_oz_mode(sbi);
DPRINTK(("autofs_lookup: pid = %u, pgrp = %u, catatonic = %d, "
"oz_mode = %d\n", task_pid_nr(current),
task_pgrp_nr(current), sbi->catatonic,
oz_mode));
/*
* Mark the dentry incomplete, but add it. This is needed so
* that the VFS layer knows about the dentry, and we can count
* on catching any lookups through the revalidate.
*
* Let all the hard work be done by the revalidate function that
* needs to be able to do this anyway..
*
* We need to do this before we release the directory semaphore.
*/
dentry->d_op = &autofs_dentry_operations;
dentry->d_flags |= DCACHE_AUTOFS_PENDING;
d_add(dentry, NULL);
mutex_unlock(&dir->i_mutex);
autofs_revalidate(dentry, nd);
mutex_lock(&dir->i_mutex);
/*
* If we are still pending, check if we had to handle
* a signal. If so we can force a restart..
*/
if (dentry->d_flags & DCACHE_AUTOFS_PENDING) {
/* See if we were interrupted */
if (signal_pending(current)) {
sigset_t *sigset = ¤t->pending.signal;
if (sigismember (sigset, SIGKILL) ||
sigismember (sigset, SIGQUIT) ||
sigismember (sigset, SIGINT)) {
unlock_kernel();
return ERR_PTR(-ERESTARTNOINTR);
}
}
}
unlock_kernel();
/*
* If this dentry is unhashed, then we shouldn't honour this
* lookup even if the dentry is positive. Returning ENOENT here
* doesn't do the right thing for all system calls, but it should
* be OK for the operations we permit from an autofs.
*/
if (dentry->d_inode && d_unhashed(dentry))
return ERR_PTR(-ENOENT);
return NULL;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:69,代码来源:root.c
示例8: esdfs_d_revalidate
/*
* returns: -ERRNO if error (returned to user)
* 0: tell VFS to invalidate dentry
* 1: dentry is valid
*/
static int esdfs_d_revalidate(struct dentry *dentry, struct nameidata *nd)
{
struct path lower_path;
struct path lower_parent_path;
struct dentry *parent_dentry = NULL;
struct dentry *lower_dentry = NULL;
struct dentry *lower_parent_dentry = NULL;
int err = 1;
if (nd && (nd->flags & LOOKUP_RCU))
return -ECHILD;
/* short-circuit if it's root */
spin_lock(&dentry->d_lock);
if (IS_ROOT(dentry)) {
spin_unlock(&dentry->d_lock);
return 1;
}
spin_unlock(&dentry->d_lock);
esdfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
esdfs_get_lower_parent(dentry, lower_dentry, &lower_parent_dentry);
parent_dentry = dget_parent(dentry);
esdfs_get_lower_path(parent_dentry, &lower_parent_path);
if (lower_parent_path.dentry != lower_parent_dentry)
goto drop;
/* can't do strcmp if lower is hashed */
spin_lock(&lower_dentry->d_lock);
if (d_unhashed(lower_dentry)) {
spin_unlock(&lower_dentry->d_lock);
goto drop;
}
spin_lock(&dentry->d_lock);
if (lower_dentry->d_name.len != dentry->d_name.len ||
strncasecmp(lower_dentry->d_name.name,
dentry->d_name.name,
dentry->d_name.len) != 0) {
err = 0;
__d_drop(dentry); /* already holding spin lock */
}
spin_unlock(&dentry->d_lock);
spin_unlock(&lower_dentry->d_lock);
esdfs_revalidate_perms(dentry);
goto out;
drop:
d_drop(dentry);
err = 0;
out:
esdfs_put_lower_path(parent_dentry, &lower_parent_path);
dput(parent_dentry);
esdfs_put_lower_parent(dentry, &lower_parent_dentry);
esdfs_put_lower_path(dentry, &lower_path);
return err;
}
开发者ID:marcelotorres1982,项目名称:kernel-msm,代码行数:69,代码来源:dentry.c
示例9: osi_TryEvictVCache
int
osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
int code;
struct dentry *dentry;
struct inode *inode = AFSTOV(avc);
struct list_head *cur, *head;
/* First, see if we can evict the inode from the dcache */
if (defersleep && avc != afs_globalVp && VREFCOUNT(avc) > 1 && avc->opens == 0) {
*slept = 1;
ReleaseWriteLock(&afs_xvcache);
AFS_GUNLOCK();
#if defined(HAVE_DCACHE_LOCK)
spin_lock(&dcache_lock);
head = &inode->i_dentry;
restart:
cur = head;
while ((cur = cur->next) != head) {
dentry = list_entry(cur, struct dentry, d_alias);
if (d_unhashed(dentry))
continue;
dget_locked(dentry);
spin_unlock(&dcache_lock);
if (d_invalidate(dentry) == -EBUSY) {
dput(dentry);
/* perhaps lock and try to continue? (use cur as head?) */
goto inuse;
}
dput(dentry);
spin_lock(&dcache_lock);
goto restart;
}
spin_unlock(&dcache_lock);
#else /* HAVE_DCACHE_LOCK */
spin_lock(&inode->i_lock);
head = &inode->i_dentry;
restart:
cur = head;
while ((cur = cur->next) != head) {
dentry = list_entry(cur, struct dentry, d_alias);
spin_lock(&dentry->d_lock);
if (d_unhashed(dentry)) {
spin_unlock(&dentry->d_lock);
continue;
}
spin_unlock(&dentry->d_lock);
dget(dentry);
spin_unlock(&inode->i_lock);
if (d_invalidate(dentry) == -EBUSY) {
dput(dentry);
/* perhaps lock and try to continue? (use cur as head?) */
goto inuse;
}
dput(dentry);
spin_lock(&inode->i_lock);
goto restart;
}
spin_unlock(&inode->i_lock);
#endif /* HAVE_DCACHE_LOCK */
inuse:
AFS_GLOCK();
ObtainWriteLock(&afs_xvcache, 733);
}
开发者ID:sanchit-matta,项目名称:openafs,代码行数:71,代码来源:osi_vcache.c
示例10: talpa__d_path
//.........这里部分代码省略.........
{
critical("talpa__d_path: d_path returned an error: %ld",PTR_ERR(path));
path = NULL;
}
if ( NULL != path )
{
return path;
}
}
# endif /* TALPA_D_DNAME_DIRECT_DPATH */
# if defined TALPA_DPATH_SLES11
path = kernel_d_path(&pathPath, &rootPath, buffer, buflen, 0);
# elif defined TALPA_DPATH_PATH
path = kernel_d_path(&pathPath, &rootPath, buffer, buflen);
# elif defined TALPA_DPATH_SUSE103
path = kernel_d_path(dentry, vfsmnt, root, rootmnt, buffer, buflen, 0);
# else
path = kernel_d_path(dentry, vfsmnt, root, rootmnt, buffer, buflen);
# endif
#else
/* Call our own version */
path = __talpa_d_path(dentry, vfsmnt, root, rootmnt, buffer, buflen);
#endif
#if defined HOLD_DCACHE_LOCK_WHILE_CALLING_D_PATH
spin_unlock(&dcache_lock);
#endif
if ( unlikely( IS_ERR(path) != 0 ) )
{
critical("talpa__d_path: kernel__d_path returned an error: %ld",PTR_ERR(path));
path = NULL;
}
else if ( unlikely( NULL == path ) )
{
#ifdef TALPA_D_DNAME_DIRECT_DPATH
/* only use this as a fall-back, it will only return the relative path from a chroot
* Use this in cases where kernel_d_path fails to return a valid path for bind mounts
* in newer kernel in a systemd environment */
path = d_path(&pathPath, buffer, buflen);
if ( unlikely( IS_ERR(path) != 0 ) )
{
critical("talpa__d_path: kernel_d_path returned an error: %ld",PTR_ERR(path));
path = NULL;
}
if (dentry->d_op && dentry->d_op->d_dname)
{
dbg(" dpath=%s",path);
err("dpath=%s - dentry has d_op and d_dname=%p",path,dentry->d_op->d_dname);
}
#endif
if ( NULL == path )
{
if (!IS_ROOT(dentry) && d_unhashed(dentry)) {
dbg("talpa__d_path: kernel_d_path returned NULL for deleted file");
dbg(" basename=%s",dentry->d_name.name);
}
else
{
info("talpa__d_path: kernel_d_path returned NULL for non-deleted file");
info(" basename=%s",dentry->d_name.name);
}
}
else
{
if (!IS_ROOT(dentry) && d_unhashed(dentry))
{
dbg(" talpa__d_path: kernel_d_path returned NULL but d_path returned path %s for deleted file",path);
}
else
{
/* the systemd / containers / bind mount case.
*
* Now so common that we don't want to even debug log it
* dbg(" talpa__d_path: kernel_d_path returned NULL but d_path returned path %s for non-deleted file",path);
*/
#ifdef TALPA_MNT_NAMESPACE
if (NULL != getNamespaceInfo(vfsmnt) && (!S_ISDIR(dentry->d_inode->i_mode)))
{
/* we're in a namespace/container */
if (nonRootNamespaceOut != NULL)
{
*nonRootNamespaceOut = true;
}
}
if (false)
{
debugPathWalk(dentry, vfsmnt, root, rootmnt);
}
#endif
}
}
}
return path;
}
开发者ID:sophos,项目名称:talpa,代码行数:101,代码来源:glue.c
示例11: __talpa_d_path
/**
* d_path - return the path of a dentry
* @dentry: dentry to report
* @vfsmnt: vfsmnt to which the dentry belongs
* @root: root dentry
* @rootmnt: vfsmnt to which the root dentry belongs
* @buffer: buffer to return value in
* @buflen: buffer length
*
* Convert a dentry into an ASCII path name. If the entry has been deleted
* the string " (deleted)" is appended. Note that this is ambiguous.
*
* Returns the buffer or an error code if the path was too long.
*
* "buflen" should be positive. Caller holds the dcache_lock.
*/
static char * __talpa_d_path( struct dentry *dentry, struct vfsmount *vfsmnt,
struct dentry *root, struct vfsmount *rootmnt,
char *buffer, int buflen)
{
char * end = buffer+buflen;
char * retval;
int namelen;
unsigned m_seq = 1;
*--end = '\0';
buflen--;
if (!IS_ROOT(dentry) && d_unhashed(dentry))
{
buflen -= 10;
end -= 10;
if (buflen < 0)
goto Elong;
memcpy(end, " (deleted)", 10);
}
if (buflen < 1)
goto Elong;
/* Get '/' right */
retval = end-1;
*retval = '/';
for (;;) {
struct dentry * parent;
if (dentry == root && vfsmnt == rootmnt)
break;
if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry))
{
/* Global root? */
talpa_vfsmount_lock(&m_seq);
if (vfsmnt->mnt_parent == vfsmnt) {
talpa_vfsmount_unlock(&m_seq);
goto global_root;
}
dentry = vfsmnt->mnt_mountpoint;
vfsmnt = vfsmnt->mnt_parent;
talpa_vfsmount_unlock(&m_seq);
continue;
}
parent = dentry->d_parent;
prefetch(parent);
namelen = dentry->d_name.len;
buflen -= namelen + 1;
if (buflen < 0)
goto Elong;
end -= namelen;
memcpy(end, dentry->d_name.name, namelen);
*--end = '/';
retval = end;
dentry = parent;
}
return retval;
global_root:
namelen = dentry->d_name.len;
buflen -= namelen;
if (buflen < 0)
goto Elong;
retval -= namelen-1; /* hit the slash */
memcpy(retval, dentry->d_name.name, namelen);
return retval;
Elong:
return ERR_PTR(-ENAMETOOLONG);
}
开发者ID:sophos,项目名称:talpa,代码行数:86,代码来源:glue.c
示例12: hypfs_positive
static inline int hypfs_positive(struct dentry *dentry)
{
return d_really_is_positive(dentry) && !d_unhashed(dentry);
}
开发者ID:0x000000FF,项目名称:edison-linux,代码行数:4,代码来源:inode.c
示例13: au_ready_to_write
/*
* prepare the @file for writing.
*/
int au_ready_to_write(struct file *file, loff_t len)
{
int err;
struct dentry *dentry, *parent, *hidden_dentry, *hidden_parent;
struct inode *hidden_inode, *hidden_dir, *inode, *dir;
struct super_block *sb;
aufs_bindex_t bstart, bcpup;
dentry = file->f_dentry;
LKTRTrace("%.*s, len %Ld\n", DLNPair(dentry), len);
FiMustWriteLock(file);
sb = dentry->d_sb;
bstart = fbstart(file);
DEBUG_ON(ftobr(file, bstart) != stobr(sb, bstart));
inode = dentry->d_inode;
ii_read_lock_child(inode);
LKTRTrace("rdonly %d, bstart %d\n", test_ro(sb, bstart, inode), bstart);
err = test_ro(sb, bstart, inode);
ii_read_unlock(inode);
if (!err && (au_h_fptr(file)->f_mode & FMODE_WRITE))
return 0;
/* need to cpup */
parent = dentry->d_parent; // dget_parent()
di_write_lock_child(dentry);
di_write_lock_parent(parent);
bcpup = err = find_rw_parent_br(dentry, bstart);
//bcpup = err = find_rw_br(sb, bstart);
if (unlikely(err < 0))
goto out_unlock;
err = 0;
hidden_parent = au_h_dptr_i(parent, bcpup);
if (!hidden_parent) {
err = cpup_dirs(dentry, bcpup, NULL);
//if (LktrCond) err = -1;
if (unlikely(err))
goto out_unlock;
hidden_parent = au_h_dptr_i(parent, bcpup);
}
hidden_dir = hidden_parent->d_inode;
hidden_dentry = au_h_fptr(file)->f_dentry;
hidden_inode = hidden_dentry->d_inode;
dir = parent->d_inode;
hdir_lock(hidden_dir, dir, bcpup);
hi_lock_child(hidden_inode);
if (d_unhashed(dentry) || d_unhashed(hidden_dentry)
/* || !hidden_inode->i_nlink */) {
if (!au_test_perm(hidden_dir, MAY_EXEC | MAY_WRITE,
need_dlgt(sb)))
err = cpup_wh_file(file, bcpup, len);
else {
struct cpup_wh_file_args args = {
.errp = &err,
.file = file,
.bdst = bcpup,
.len = len
};
au_wkq_wait(call_cpup_wh_file, &args, /*dlgt*/0);
}
//if (LktrCond) err = -1;
TraceErr(err);
} else {
if (!au_h_dptr_i(dentry, bcpup))
开发者ID:fullstory-morgue,项目名称:aufs,代码行数:70,代码来源:file.c
示例14: cpup_wh_file
/*
* copyup the deleted file for writing.
*/
static int cpup_wh_file(struct file *file, aufs_bindex_t bdst, loff_t len)
{
int err;
struct dentry *dentry, *parent, *hidden_parent, *tmp_dentry;
struct dentry *hidden_dentry_bstart, *hidden_dentry_bdst;
struct inode *hidden_dir;
aufs_bindex_t bstart;
struct aufs_dinfo *dinfo;
struct dtime dt;
struct lkup_args lkup;
struct super_block *sb;
dentry = file->f_dentry;
LKTRTrace("%.*s, bdst %d, len %Lu\n", DLNPair(dentry), bdst, len);
DEBUG_ON(S_ISDIR(dentry->d_inode->i_mode)
|| !(file->f_mode & FMODE_WRITE));
DiMustWriteLock(dentry);
parent = dentry->d_parent;
IiMustAnyLock(parent->d_inode);
hidden_parent = au_h_dptr_i(parent, bdst);
DEBUG_ON(!hidden_parent);
hidden_dir = hidden_parent->d_inode;
DEBUG_ON(!hidden_dir);
IMustLock(hidden_dir);
sb = parent->d_sb;
lkup.nfsmnt = au_nfsmnt(sb, bdst);
lkup.dlgt = need_dlgt(sb);
tmp_dentry = lkup_whtmp(hidden_parent, &dentry->d_name, &lkup);
//if (LktrCond) {dput(tmp_dentry); tmp_dentry = ERR_PTR(-1);}
err = PTR_ERR(tmp_dentry);
if (IS_ERR(tmp_dentry))
goto out;
dtime_store(&dt, parent, hidden_parent);
dinfo = dtodi(dentry);
bstart = dinfo->di_bstart;
hidden_dentry_bdst = dinfo->di_hdentry[0 + bdst].hd_dentry;
hidden_dentry_bstart = dinfo->di_hdentry[0 + bstart].hd_dentry;
dinfo->di_bstart = bdst;
dinfo->di_hdentry[0 + bdst].hd_dentry = tmp_dentry;
dinfo->di_hdentry[0 + bstart].hd_dentry = au_h_fptr(file)->f_dentry;
err = cpup_single(dentry, bdst, bstart, len,
au_flags_cpup(!CPUP_DTIME, parent));
//if (LktrCond) err = -1;
if (!err)
err = au_reopen_nondir(file);
//err = -1;
if (unlikely(err)) {
dinfo->di_hdentry[0 + bstart].hd_dentry = hidden_dentry_bstart;
dinfo->di_hdentry[0 + bdst].hd_dentry = hidden_dentry_bdst;
dinfo->di_bstart = bstart;
goto out_tmp;
}
DEBUG_ON(!d_unhashed(dentry));
err = vfsub_unlink(hidden_dir, tmp_dentry, lkup.dlgt);
//if (LktrCond) err = -1;
if (unlikely(err)) {
IOErr("failed remove copied-up tmp file %.*s(%d)\n",
DLNPair(tmp_dentry), err);
err = -EIO;
}
dtime_revert(&dt, !CPUP_LOCKED_GHDIR);
out_tmp:
dput(tmp_dentry);
out:
TraceErr(err);
return err;
}
开发者ID:fullstory-morgue,项目名称:aufs,代码行数:74,代码来源:file.c
示例15: aufs_link
//.........这里部分代码省略.........
goto out_parent;
err = 0;
sb = dentry->d_sb;
a->bdst = au_dbstart(dentry);
a->h_path.dentry = au_h_dptr(dentry, a->bdst);
a->h_path.mnt = au_sbr_mnt(sb, a->bdst);
a->bsrc = au_ibstart(inode);
h_src_dentry = au_h_d_alias(src_dentry, a->bsrc);
if (!h_src_dentry) {
a->bsrc = au_dbstart(src_dentry);
h_src_dentry = au_h_d_alias(src_dentry, a->bsrc);
AuDebugOn(!h_src_dentry);
} else if (IS_ERR(h_src_dentry))
goto out_parent;
if (au_opt_test(au_mntflags(sb), PLINK)) {
if (a->bdst < a->bsrc
/* && h_src_dentry->d_sb != a->h_path.dentry->d_sb */)
err = au_cpup_or_link(src_dentry, a);
else
err = vfsub_link(h_src_dentry, au_pinned_h_dir(&a->pin),
&a->h_path);
dput(h_src_dentry);
} else {
/*
* copyup src_dentry to the branch we process,
* and then link(2) to it.
*/
dput(h_src_dentry);
if (a->bdst < a->bsrc
/* && h_src_dentry->d_sb != a->h_path.dentry->d_sb */) {
au_unpin(&a->pin);
di_write_unlock(a->parent);
err = au_cpup_before_link(src_dentry, a);
di_write_lock_parent(a->parent);
if (!err)
err = au_pin(&a->pin, dentry, a->bdst,
au_opt_udba(sb),
AuPin_DI_LOCKED | AuPin_MNT_WRITE);
if (unlikely(err))
goto out_wh;
}
if (!err) {
h_src_dentry = au_h_dptr(src_dentry, a->bdst);
err = -ENOENT;
if (h_src_dentry && h_src_dentry->d_inode)
err = vfsub_link(h_src_dentry,
au_pinned_h_dir(&a->pin),
&a->h_path);
}
}
if (unlikely(err))
goto out_unpin;
if (wh_dentry) {
a->h_path.dentry = wh_dentry;
err = au_wh_unlink_dentry(au_pinned_h_dir(&a->pin), &a->h_path,
dentry);
if (unlikely(err))
goto out_revert;
}
dir->i_version++;
if (au_ibstart(dir) == au_dbstart(dentry))
au_cpup_attr_timesizes(dir);
inc_nlink(inode);
inode->i_ctime = dir->i_ctime;
d_instantiate(dentry, au_igrab(inode));
if (d_unhashed(a->h_path.dentry))
/* some filesystem calls d_drop() */
d_drop(dentry);
goto out_unpin; /* success */
out_revert:
rerr = vfsub_unlink(au_pinned_h_dir(&a->pin), &a->h_path, /*force*/0);
if (unlikely(rerr)) {
AuIOErr("%.*s reverting failed(%d, %d)\n",
AuDLNPair(dentry), err, rerr);
err = -EIO;
}
au_dtime_revert(&dt);
out_unpin:
au_unpin(&a->pin);
out_wh:
dput(wh_dentry);
out_parent:
di_write_unlock(a->parent);
dput(a->src_parent);
out_unlock:
if (unlikely(err)) {
au_update_dbstart(dentry);
d_drop(dentry);
}
aufs_read_and_write_unlock2(dentry, src_dentry);
out_kfree:
kfree(a);
out:
return err;
}
开发者ID:Jman420,项目名称:nanoBoot-DSM5.1,代码行数:101,代码来源:i_op_add.c
示例16: au_ready_to_write
/*
* prepare the @file for writing.
*/
int au_ready_to_write(struct file *file, loff_t len, struct au_pin *pin)
{
int err;
aufs_bindex_t bstart, bcpup;
struct dentry *dentry, *parent, *h_dentry;
struct inode *h_inode, *inode;
struct super_block *sb;
struct file *h_file;
dentry = file->f_dentry;
sb = dentry->d_sb;
inode = dentry->d_inode;
AuDebugOn(au_special_file(inode->i_mode));
bstart = au_fbstart(file);
err = au_test_ro(sb, bstart, inode);
if (!err && (au_hf_top(file)->f_mode & FMODE_WRITE)) {
err = au_pin(pin, dentry, bstart, AuOpt_UDBA_NONE, /*flags*/0);
goto out;
}
/* need to cpup */
parent = dget_parent(dentry);
di_write_lock_parent(parent);
err = AuWbrCopyup(au_sbi(sb), dentry);
bcpup = err;
if (unlikely(err < 0))
goto out_dgrade;
err = 0;
if (!au_h_dptr(parent, bcpup)) {
err = au_cpup_dirs(dentry, bcpup);
if (unlikely(err))
goto out_dgrade;
}
err = au_pin(pin, dentry, bcpup, AuOpt_UDBA_NONE,
AuPin_DI_LOCKED | AuPin_MNT_WRITE);
if (unlikely(err))
goto out_dgrade;
h_dentry = au_hf_top(file)->f_dentry;
h_inode = h_dentry->d_inode;
mutex_lock_nested(&h_inode->i_mutex, AuLsc_I_CHILD);
h_file = au_h_open_pre(dentry, bstart);
if (IS_ERR(h_file)) {
err = PTR_ERR(h_file);
h_file = NULL;
} else if (d_unhashed(dentry) /* || d_unhashed(h_dentry) */
/* || !h_inode->i_nlink */) {
err = au_ready_to_write_wh(file, len, bcpup);
di_downgrade_lock(parent, AuLock_IR);
} else {
di_downgrade_lock(parent, AuLock_IR);
if (!au_h_dptr(dentry, bcpup))
err = au_sio_cpup_simple(dentry, bcpup, len,
AuCpup_DTIME);
if (!err)
err = au_reopen_nondir(file);
}
mutex_unlock(&h_inode->i_mutex);
au_h_open_post(dentry, bstart, h_file);
if (!err) {
au_pin_set_parent_lflag(pin, /*lflag*/0);
goto out_dput; /* success */
}
au_unpin(pin);
goto out_unlock;
out_dgrade:
di_downgrade_lock(parent, AuLock_IR);
out_unlock:
di_read_unlock(parent, AuLock_IR);
out_dput:
dput(parent);
out:
return err;
}
开发者ID:duand,项目名称:htc-kernel-wildfire-2.6.32,代码行数:81,代码来源:file.c
示例17: wrapfs_open
static int wrapfs_open(struct inode *inode, struct file *file)
{
int err = 0;
struct file *lower_file = NULL;
struct path lower_path;
#ifdef EXTRA_CREDIT
int CHKSUM_SIZE =0;
char *algo = kmalloc(sizeof(char)*10,GFP_KERNEL);
int *algo_len = kmalloc(sizeof(char)*1,GFP_KERNEL);
char *chkbuf = kmalloc(sizeof(char)*32,GFP_KERNEL);
char *getchkbuf = kmalloc(sizeof(char)*32,GFP_KERNEL);
#else
char *chkbuf = kmalloc(sizeof(char)*CHKSUM_SIZE,GFP_KERNEL);
char *getchkbuf = kmalloc(sizeof(char)*CHKSUM_SIZE,GFP_KERNEL);
#endif
char *has_integrity = kmalloc(sizeof(char)*1,GFP_KERNEL);
int rc = 0;
if(!chkbuf || !has_integrity || !getchkbuf)
{
err = -ENOMEM;
goto out_err;
}
/* don't open unhashed/deleted files */
if (d_unhashed(file->f_path.dentry)) {
err = -ENOENT;
goto out_err;
}
file->private_data =
kzalloc(sizeof(struct wrapfs_file_info), GFP_KERNEL);
if (!WRAPFS_F(file)) {
err = -ENOMEM;
goto out_err;
}
/* open lower object and link wrapfs's file struct to lower's */
wrapfs_get_lower_path(file->f_path.dentry, &lower_path);
lower_file = dentry_open(lower_path.dentry, lower_path.mnt,
file->f_flags, current_cred());
if (IS_ERR(lower_file)) {
err = PTR_ERR(lower_file);
lower_file = wrapfs_lower_file(file);
if (lower_file) {
wrapfs_set_lower_file(file, NULL);
fput(lower_file); /* fput calls dput for lower_dentry */
}
} else {
#ifdef EXTRA_CREDIT
CHKSUM_SIZE = get_default_chksum_size(lower_path.dentry,algo,algo_len);
#endif
rc = vfs_getxattr(lower_path.dentry,XATTR_HAS_INTEGRITY,has_integrity,1);
if(rc > 0 && !S_ISDIR(lower_path.dentry->d_inode->i_mode))
{
wrapfs_set_lower_file(file,lower_file);
if(lower_file->f_mode == O_TRUNC)
wrapfs_set_write_dirty(inode,WRITE_DIRTY_BIT);
if(!memcmp(has_integrity,"1",1) && wrapfs_get_write_dirty(inode)!=WRITE_DIRTY_BIT && rc ==1)
{
if(vfs_getxattr(lower_path.dentry,XATTR_INTEGRITY_VAL,chkbuf,CHKSUM_SIZE)>0)
{
//mutex_lock(&lower_path.dentry->d_inode->i_mutex);
calculate_checksum(lower_file,getchkbuf,CHKSUM_SIZE);
if(memcmp(chkbuf,getchkbuf,CHKSUM_SIZE))
{
printk("Integrity mismatch\n");
err = -EPERM;
wrapfs_set_lower_file(file,NULL);
fput(lower_file);
}
//mutex_unlock(&lower_path.dentry->d_inode->i_mutex);
}
}
else if(!memcmp(has_integrity,"0",1) && rc ==1)
{
if(vfs_getxattr(lower_path.dentry,XATTR_INTEGRITY_VAL,chkbuf,CHKSUM_SIZE)>0)
{
err = -EIO;
wrapfs_set_lower_file(file,NULL);
fput(lower_file);
}
else
wrapfs_set_lower_file(file,lower_file);
}
else
{
printk("File corrupted.Unexpected value for has_integrity attribute\n");
err = -EPERM;
wrapfs_set_lower_file(file,NULL);
fput(lower_file);
}
}
else if(vfs_getxattr(lower_path.dentry,XATTR_HAS_INTEGRITY,has_integrity,1)<=0 && vfs_getxattr(lower_path.dentry,XATTR_INTEGRITY_VAL,chkbuf,CHKSUM_SIZE)>0)
{
err = -EIO;
wrapfs_set_lower_file(file,NULL);
fput(lower_file);
}
//.........这里部分代码省略.........
开发者ID:sudheerkv,项目名称:CSE506,代码行数:101,代码来源:file.c
示例18: au_file_refresh_by_inode
static int au_file_refresh_by_inode(struct file *file, int *need_reopen)
{
int err;
aufs_bindex_t bstart;
struct au_pin pin;
struct au_finfo *finfo;
struct dentry *dentry, *parent, *hi_wh;
struct inode *inode;
struct super_block *sb;
FiMustWriteLock(file);
err = 0;
finfo = au_fi(file);
dentry = file->f_dentry;
sb = dentry->d_sb;
inode = dentry->d_inode;
bstart = au_ibstart(inode);
if (bstart == finfo->fi_btop)
goto out;
parent = dget_parent(dentry);
if (au_test_ro(sb, bstart, inode)) {
di_read_lock_parent(parent, !AuLock_IR);
err = AuWbrCopyup(au_sbi(sb), dentry);
bstart = err;
di_read_unlock(parent, !AuLock_IR);
if (unlikely(err < 0))
goto out_parent;
err = 0;
}
di_read_lock_parent(parent, AuLock_IR);
hi_wh = au_hi_wh(inode, bstart);
if (au_opt_test(au_mntflags(sb), PLINK)
&& au_plink_test(inode)
&& !d_unhashed(dentry)) {
err = au_test_and_cpup_dirs(dentry, bstart);
if (unlikely(err))
goto out_unlock;
/* always superio. */
err = au_pin(&pin, dentry, bstart, AuOpt_UDBA_NONE,
AuPin_DI_LOCKED | AuPin_MNT_WRITE);
if (!err)
err = au_sio_cpup_simple(dentry, bstart, -1,
AuCpup_DTIME);
au_unpin(&pin);
} else if (hi_wh) {
/* already copied-up after unlink */
err = au_reopen_wh(file, bstart, hi_wh);
*need_reopen = 0;
}
out_unlock:
di_read_unlock(parent, AuLock_IR);
out_parent:
dput(parent);
out:
return err;
}
开发者ID:duand,项目名称:htc-kernel-wildfire-2.6.32,代码行数:61,代码来源:file.c
示例19: h_d_revalidate
/* todo: remove this */
static int h_d_revalidate(struct dentry *dentry, struct inode *inode,
struct nameidata *nd, int do_udba)
{
int err;
umode_t mode, h_mode;
aufs_bindex_t bind
|
请发表评论