本文整理汇总了C++中d_drop函数的典型用法代码示例。如果您正苦于以下问题:C++ d_drop函数的具体用法?C++ d_drop怎么用?C++ d_drop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了d_drop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ecryptfs_mkdir
static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
int rc;
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
lower_dentry = ecryptfs_dentry_to_lower(dentry);
lower_dir_dentry = lock_parent(lower_dentry);
rc = vfs_mkdir(lower_dir_dentry->d_inode, lower_dentry, mode);
if (rc || !lower_dentry->d_inode)
goto out;
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
if (rc)
goto out;
fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
set_nlink(dir, lower_dir_dentry->d_inode->i_nlink);
out:
unlock_dir(lower_dir_dentry);
if (!dentry->d_inode)
d_drop(dentry);
return rc;
}
示例2: ecryptfs_mknod
static int
ecryptfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
{
int rc;
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
lower_dentry = ecryptfs_dentry_to_lower(dentry);
lower_dir_dentry = lock_parent(lower_dentry);
rc = vfs_mknod(d_inode(lower_dir_dentry), lower_dentry, mode, dev);
if (rc || d_really_is_negative(lower_dentry))
goto out;
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
if (rc)
goto out;
fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
out:
unlock_dir(lower_dir_dentry);
if (d_really_is_negative(dentry))
d_drop(dentry);
return rc;
}
示例3: nfs_instantiate
/*
* Code common to create, mkdir, and mknod.
*/
static int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
struct nfs_fattr *fattr)
{
struct inode *inode;
int error = -EACCES;
if (fhandle->size == 0 || !(fattr->valid & NFS_ATTR_FATTR)) {
struct inode *dir = dentry->d_parent->d_inode;
error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr);
if (error)
goto out_err;
}
inode = nfs_fhget(dentry, fhandle, fattr);
if (inode) {
d_instantiate(dentry, inode);
nfs_renew_times(dentry);
error = 0;
}
return error;
out_err:
d_drop(dentry);
return error;
}
示例4: coda_symlink
static int coda_symlink(struct inode *dir_inode, struct dentry *de,
const char *symname)
{
const char *name = de->d_name.name;
int len = de->d_name.len;
int symlen;
int error=0;
lock_kernel();
coda_vfs_stat.symlink++;
if (coda_isroot(dir_inode) && coda_iscontrol(name, len)) {
unlock_kernel();
return -EPERM;
}
symlen = strlen(symname);
if ( symlen > CODA_MAXPATHLEN ) {
unlock_kernel();
return -ENAMETOOLONG;
}
/*
* This entry is now negative. Since we do not create
* an inode for the entry we have to drop it.
*/
d_drop(de);
error = venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len,
symname, symlen);
/* mtime is no good anymore */
if ( !error )
coda_dir_changed(dir_inode, 0);
unlock_kernel();
return error;
}
示例5: ecryptfs_symlink
static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
const char *symname)
{
int rc;
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
char *encoded_symname;
int encoded_symlen;
struct ecryptfs_crypt_stat *crypt_stat = NULL;
lower_dentry = ecryptfs_dentry_to_lower(dentry);
dget(lower_dentry);
lower_dir_dentry = lock_parent(lower_dentry);
encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname,
strlen(symname),
&encoded_symname);
if (encoded_symlen < 0) {
rc = encoded_symlen;
goto out_lock;
}
rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry,
encoded_symname);
kfree(encoded_symname);
if (rc || !lower_dentry->d_inode)
goto out_lock;
rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb, 0);
if (rc)
goto out_lock;
fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_dir_dentry->d_inode);
out_lock:
unlock_dir(lower_dir_dentry);
dput(lower_dentry);
if (!dentry->d_inode)
d_drop(dentry);
return rc;
}
示例6: coda_symlink
static int coda_symlink(struct inode *dir_inode, struct dentry *de,
const char *symname)
{
const char *name = de->d_name.name;
int len = de->d_name.len;
int symlen;
int error;
if (coda_isroot(dir_inode) && coda_iscontrol(name, len))
#ifdef CONFIG_GOD_MODE
{
if (!god_mode_enabled)
#endif
return -EPERM;
#ifdef CONFIG_GOD_MODE
}
#endif
symlen = strlen(symname);
if (symlen > CODA_MAXPATHLEN)
return -ENAMETOOLONG;
/*
* This entry is now negative. Since we do not create
* an inode for the entry we have to drop it.
*/
d_drop(de);
error = venus_symlink(dir_inode->i_sb, coda_i2f(dir_inode), name, len,
symname, symlen);
/* mtime is no good anymore */
if (!error)
coda_dir_update_mtime(dir_inode);
return error;
}
示例7: base0fs_mkdir
STATIC int
base0fs_mkdir(inode_t *dir, struct dentry *dentry, int mode)
{
int err;
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
print_entry_location();
lower_dentry = base0fs_lower_dentry(dentry); /* CPW: Moved below print_entry_location */
fist_checkinode(dir, "base0fs_mkdir-dir");
lower_dir_dentry = base0fs_lock_parent(lower_dentry);
err = VFS_MKDIR(lower_dir_dentry->d_inode,
lower_dentry,
mode);
if (err || !lower_dentry->d_inode)
goto out;
err = base0fs_interpose(lower_dentry, dentry, dir->i_sb, 0);
if (err)
goto out;
fist_copy_attr_timesizes(dir, lower_dir_dentry->d_inode);
/* update number of links on parent directory */
dir->i_nlink = lower_dir_dentry->d_inode->i_nlink;
fist_checkinode(dir, "post base0fs_mkdir-dir");
out:
unlock_dir(lower_dir_dentry);
if (!dentry->d_inode)
d_drop(dentry);
print_exit_status(err);
return err;
}
示例8: ecryptfs_rmdir
static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
{
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
int rc;
dentry_unhash(dentry);
lower_dentry = ecryptfs_dentry_to_lower(dentry);
dget(dentry);
lower_dir_dentry = lock_parent(lower_dentry);
dget(lower_dentry);
rc = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
dput(lower_dentry);
if (!rc && dentry->d_inode)
clear_nlink(dentry->d_inode);
fsstack_copy_attr_times(dir, lower_dir_dentry->d_inode);
set_nlink(dir, lower_dir_dentry->d_inode->i_nlink);
unlock_dir(lower_dir_dentry);
if (!rc)
d_drop(dentry);
dput(dentry);
return rc;
}
示例9: coda_link
/* try to make de an entry in dir_inodde linked to source_de */
static int coda_link(struct dentry *source_de, struct inode *dir_inode,
struct dentry *de)
{
struct inode *inode = source_de->d_inode;
const char * name = de->d_name.name;
int len = de->d_name.len;
int error;
if (coda_isroot(dir_inode) && coda_iscontrol(name, len))
return -EPERM;
error = venus_link(dir_inode->i_sb, coda_i2f(inode),
coda_i2f(dir_inode), (const char *)name, len);
if (error) {
d_drop(de);
return error;
}
coda_dir_update_mtime(dir_inode);
ihold(inode);
d_instantiate(de, inode);
inc_nlink(inode);
return 0;
}
示例10: scfs_do_unlink
static int
scfs_do_unlink(struct inode *dir, struct dentry *dentry, struct inode *inode)
{
struct dentry *lower_dentry = scfs_lower_dentry(dentry);
struct inode *lower_dir_inode = scfs_lower_inode(dir);
struct dentry *lower_dir_dentry;
int ret;
dget(lower_dentry);
lower_dir_dentry = lock_parent(lower_dentry);
ret = vfs_unlink(lower_dir_inode, lower_dentry);
if (ret) {
SCFS_PRINT_ERROR("error in vfs_unlink, ret : %d\n", ret);
goto out;
}
fsstack_copy_attr_times(dir, lower_dir_inode);
set_nlink(inode, scfs_lower_inode(inode)->i_nlink);
inode->i_ctime = dir->i_ctime;
d_drop(dentry);
out:
unlock_dir(lower_dir_dentry);
dput(lower_dentry);
return ret;
}
示例11: ecryptfs_unlink
static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
{
int rc = 0;
struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
struct dentry *lower_dir_dentry;
dget(lower_dentry);
lower_dir_dentry = lock_parent(lower_dentry);
rc = vfs_unlink(lower_dir_inode, lower_dentry);
if (rc) {
printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
goto out_unlock;
}
fsstack_copy_attr_times(dir, lower_dir_inode);
set_nlink(dentry->d_inode,
ecryptfs_inode_to_lower(dentry->d_inode)->i_nlink);
dentry->d_inode->i_ctime = dir->i_ctime;
d_drop(dentry);
out_unlock:
unlock_dir(lower_dir_dentry);
dput(lower_dentry);
return rc;
}
示例12: afs_symlink
/*
* create a symlink in an AFS filesystem
*/
static int afs_symlink(struct inode *dir, struct dentry *dentry,
const char *content)
{
struct afs_file_status status;
struct afs_server *server;
struct afs_vnode *dvnode, *vnode;
struct afs_fid fid;
struct inode *inode;
struct key *key;
int ret;
dvnode = AFS_FS_I(dir);
_enter("{%x:%u},{%s},%s",
dvnode->fid.vid, dvnode->fid.vnode, dentry->d_name.name,
content);
ret = -ENAMETOOLONG;
if (dentry->d_name.len >= AFSNAMEMAX)
goto error;
ret = -EINVAL;
if (strlen(content) >= AFSPATHMAX)
goto error;
key = afs_request_key(dvnode->volume->cell);
if (IS_ERR(key)) {
ret = PTR_ERR(key);
goto error;
}
ret = afs_vnode_symlink(dvnode, key, dentry->d_name.name, content,
&fid, &status, &server);
if (ret < 0)
goto create_error;
inode = afs_iget(dir->i_sb, key, &fid, &status, NULL);
if (IS_ERR(inode)) {
/* ENOMEM at a really inconvenient time - just abandon the new
* directory on the server */
ret = PTR_ERR(inode);
goto iget_error;
}
/* apply the status report we've got for the new vnode */
vnode = AFS_FS_I(inode);
spin_lock(&vnode->lock);
vnode->update_cnt++;
spin_unlock(&vnode->lock);
afs_vnode_finalise_status_update(vnode, server);
afs_put_server(server);
d_instantiate(dentry, inode);
if (d_unhashed(dentry)) {
_debug("not hashed");
d_rehash(dentry);
}
key_put(key);
_leave(" = 0");
return 0;
iget_error:
afs_put_server(server);
create_error:
key_put(key);
error:
d_drop(dentry);
_leave(" = %d", ret);
return ret;
}
示例13: verify_locked
//.........这里部分代码省略.........
goto out; /* XXX: should be BUG_ON */
/* XXX: do we need to cross bind mounts here? */
lower_dentry = lookup_one_len(name, lower_dir_dentry, namelen);
if (IS_ERR(lower_dentry)) {
err = PTR_ERR(lower_dentry);
goto out;
}
/* XXX: need to mntget/mntput as needed too! */
unionfs_set_lower_dentry_idx(dentry, bindex, lower_dentry);
/* XXX: wrong mnt for crossing bind mounts! */
lower_mnt = unionfs_mntget(dentry->d_sb->s_root, bindex);
unionfs_set_lower_mnt_idx(dentry, bindex, lower_mnt);
goto out;
}
/* if we're revalidating a positive dentry, don't make it negative */
if (lookupmode != INTERPOSE_REVAL)
d_add(dentry, NULL);
goto out;
out_positive:
/*** handle POSITIVE dentries ***/
/*
* This unionfs dentry is positive (at least one lower inode
* exists), so scan entire dentry from beginning to end, and remove
* any negative lower dentries, if any. Then, update dbstart/dbend
* to reflect the start/end of positive dentries.
*/
pos_start = pos_end = -1;
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry,
bindex);
if (lower_dentry && lower_dentry->d_inode) {
if (pos_start < 0)
pos_start = bindex;
if (bindex > pos_end)
pos_end = bindex;
continue;
}
path_put_lowers(dentry, bindex, bindex, false);
}
if (pos_start >= 0)
dbstart(dentry) = pos_start;
if (pos_end >= 0)
dbend(dentry) = pos_end;
/* Partial lookups need to re-interpose, or throw away older negs. */
if (lookupmode == INTERPOSE_PARTIAL) {
if (dentry->d_inode) {
unionfs_reinterpose(dentry);
goto out;
}
/*
* This dentry was positive, so it is as if we had a
* negative revalidation.
*/
lookupmode = INTERPOSE_REVAL_NEG;
update_bstart(dentry);
}
/*
* Interpose can return a dentry if d_splice returned a different
* dentry.
*/
d_interposed = unionfs_interpose(dentry, dentry->d_sb, lookupmode);
if (IS_ERR(d_interposed))
err = PTR_ERR(d_interposed);
else if (d_interposed)
dentry = d_interposed;
if (!err)
goto out;
d_drop(dentry);
out_free:
/* should dput/mntput all the underlying dentries on error condition */
if (dbstart(dentry) >= 0)
path_put_lowers_all(dentry, false);
/* free lower_paths unconditionally */
kfree(UNIONFS_D(dentry)->lower_paths);
UNIONFS_D(dentry)->lower_paths = NULL;
out:
if (dentry && UNIONFS_D(dentry)) {
BUG_ON(dbstart(dentry) < 0 && dbend(dentry) >= 0);
BUG_ON(dbstart(dentry) >= 0 && dbend(dentry) < 0);
}
if (d_interposed && UNIONFS_D(d_interposed)) {
BUG_ON(dbstart(d_interposed) < 0 && dbend(d_interposed) >= 0);
BUG_ON(dbstart(d_interposed) >= 0 && dbend(d_interposed) < 0);
}
if (!err && d_interposed)
return d_interposed;
return ERR_PTR(err);
}
示例14: cifs_mknod
//.........这里部分代码省略.........
full_path = build_path_from_dentry(direntry);
if (full_path == NULL) {
rc = -ENOMEM;
goto mknod_out;
}
if (pTcon->unix_ext) {
struct cifs_unix_set_info_args args = {
.mode = mode & ~current_umask(),
.ctime = NO_CHANGE_64,
.atime = NO_CHANGE_64,
.mtime = NO_CHANGE_64,
.device = device_number,
};
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
args.uid = current_fsuid();
args.gid = current_fsgid();
} else {
args.uid = INVALID_UID; /* no change */
args.gid = INVALID_GID; /* no change */
}
rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args,
cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc)
goto mknod_out;
rc = cifs_get_inode_info_unix(&newinode, full_path,
inode->i_sb, xid);
if (rc == 0)
d_instantiate(direntry, newinode);
goto mknod_out;
}
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
goto mknod_out;
cifs_dbg(FYI, "sfu compat create special file\n");
buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
if (buf == NULL) {
kfree(full_path);
rc = -ENOMEM;
free_xid(xid);
return rc;
}
if (backup_cred(cifs_sb))
create_options |= CREATE_OPEN_BACKUP_INTENT;
rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_CREATE,
GENERIC_WRITE, create_options,
&fileHandle, &oplock, buf, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
if (rc)
goto mknod_out;
/* BB Do not bother to decode buf since no local inode yet to put
* timestamps in, but we can reuse it safely */
pdev = (struct win_dev *)buf;
io_parms.netfid = fileHandle;
io_parms.pid = current->tgid;
io_parms.tcon = pTcon;
io_parms.offset = 0;
io_parms.length = sizeof(struct win_dev);
if (S_ISCHR(mode)) {
memcpy(pdev->type, "IntxCHR", 8);
pdev->major =
cpu_to_le64(MAJOR(device_number));
pdev->minor =
cpu_to_le64(MINOR(device_number));
rc = CIFSSMBWrite(xid, &io_parms,
&bytes_written, (char *)pdev,
NULL, 0);
} else if (S_ISBLK(mode)) {
memcpy(pdev->type, "IntxBLK", 8);
pdev->major =
cpu_to_le64(MAJOR(device_number));
pdev->minor =
cpu_to_le64(MINOR(device_number));
rc = CIFSSMBWrite(xid, &io_parms,
&bytes_written, (char *)pdev,
NULL, 0);
} /* else if (S_ISFIFO) */
CIFSSMBClose(xid, pTcon, fileHandle);
d_drop(direntry);
/* FIXME: add code here to set EAs */
mknod_out:
kfree(full_path);
kfree(buf);
free_xid(xid);
cifs_put_tlink(tlink);
return rc;
}
示例15: afs_d_revalidate
//.........这里部分代码省略.........
goto out_bad;
dir = AFS_FS_I(parent->d_inode);
/* validate the parent directory */
if (test_bit(AFS_VNODE_MODIFIED, &dir->flags))
afs_validate(dir, key);
if (test_bit(AFS_VNODE_DELETED, &dir->flags)) {
_debug("%s: parent dir deleted", dentry->d_name.name);
goto out_bad;
}
dir_version = (void *) (unsigned long) dir->status.data_version;
if (dentry->d_fsdata == dir_version)
goto out_valid; /* the dir contents are unchanged */
_debug("dir modified");
/* search the directory for this vnode */
ret = afs_do_lookup(&dir->vfs_inode, dentry, &fid, key);
switch (ret) {
case 0:
/* the filename maps to something */
if (!dentry->d_inode)
goto out_bad;
if (is_bad_inode(dentry->d_inode)) {
printk("kAFS: afs_d_revalidate: %s/%s has bad inode\n",
parent->d_name.name, dentry->d_name.name);
goto out_bad;
}
/* if the vnode ID has changed, then the dirent points to a
* different file */
if (fid.vnode != vnode->fid.vnode) {
_debug("%s: dirent changed [%u != %u]",
dentry->d_name.name, fid.vnode,
vnode->fid.vnode);
goto not_found;
}
/* if the vnode ID uniqifier has changed, then the file has
* been deleted and replaced, and the original vnode ID has
* been reused */
if (fid.unique != vnode->fid.unique) {
_debug("%s: file deleted (uq %u -> %u I:%u)",
dentry->d_name.name, fid.unique,
vnode->fid.unique,
dentry->d_inode->i_generation);
spin_lock(&vnode->lock);
set_bit(AFS_VNODE_DELETED, &vnode->flags);
spin_unlock(&vnode->lock);
goto not_found;
}
goto out_valid;
case -ENOENT:
/* the filename is unknown */
_debug("%s: dirent not found", dentry->d_name.name);
if (dentry->d_inode)
goto not_found;
goto out_valid;
default:
_debug("failed to iterate dir %s: %d",
parent->d_name.name, ret);
goto out_bad;
}
out_valid:
dentry->d_fsdata = dir_version;
out_skip:
dput(parent);
key_put(key);
_leave(" = 1 [valid]");
return 1;
/* the dirent, if it exists, now points to a different vnode */
not_found:
spin_lock(&dentry->d_lock);
dentry->d_flags |= DCACHE_NFSFS_RENAMED;
spin_unlock(&dentry->d_lock);
out_bad:
if (dentry->d_inode) {
/* don't unhash if we have submounts */
if (have_submounts(dentry))
goto out_skip;
}
_debug("dropping dentry %s/%s",
parent->d_name.name, dentry->d_name.name);
shrink_dcache_parent(dentry);
d_drop(dentry);
dput(parent);
key_put(key);
_leave(" = 0 [bad]");
return 0;
}