本文整理汇总了C++中drop_nlink函数的典型用法代码示例。如果您正苦于以下问题:C++ drop_nlink函数的具体用法?C++ drop_nlink怎么用?C++ drop_nlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drop_nlink函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: zfsctl_dir_destroy
void
zfsctl_dir_destroy(void *ptr)
{
zfsvfs_t *zfsvfs = NULL;
ASSERT(ptr);
zfsvfs = (zfsvfs_t *) ptr;
drop_nlink(LZFS_VTOI(zfsvfs->z_ctldir));
mutex_destroy(&(zfsvfs->z_ctldir->v_lock));
}
示例2: hpfs_rmdir
static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
{
const unsigned char *name = dentry->d_name.name;
unsigned len = dentry->d_name.len;
struct quad_buffer_head qbh;
struct hpfs_dirent *de;
struct inode *inode = dentry->d_inode;
dnode_secno dno;
int n_items = 0;
int err;
int r;
hpfs_adjust_length(name, &len);
hpfs_lock(dir->i_sb);
err = -ENOENT;
de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh);
if (!de)
goto out;
err = -EPERM;
if (de->first)
goto out1;
err = -ENOTDIR;
if (!de->directory)
goto out1;
hpfs_count_dnodes(dir->i_sb, hpfs_i(inode)->i_dno, NULL, NULL, &n_items);
err = -ENOTEMPTY;
if (n_items)
goto out1;
r = hpfs_remove_dirent(dir, dno, de, &qbh, 1);
switch (r) {
case 1:
hpfs_error(dir->i_sb, "there was error when removing dirent");
err = -EFSERROR;
break;
case 2:
err = -ENOSPC;
break;
default:
drop_nlink(dir);
clear_nlink(inode);
err = 0;
}
goto out;
out1:
hpfs_brelse4(&qbh);
out:
if (!err)
hpfs_update_directory_times(dir);
hpfs_unlock(dir->i_sb);
return err;
}
示例3: efivarfs_file_write
static ssize_t efivarfs_file_write(struct file *file,
const char __user *userbuf, size_t count, loff_t *ppos)
{
struct efivar_entry *var = file->private_data;
void *data;
u32 attributes;
struct inode *inode = file->f_mapping->host;
unsigned long datasize = count - sizeof(attributes);
ssize_t bytes = 0;
bool set = false;
if (count < sizeof(attributes))
return -EINVAL;
if (copy_from_user(&attributes, userbuf, sizeof(attributes)))
return -EFAULT;
if (attributes & ~(EFI_VARIABLE_MASK))
return -EINVAL;
data = kmalloc(datasize, GFP_KERNEL);
if (!data)
return -ENOMEM;
if (copy_from_user(data, userbuf + sizeof(attributes), datasize)) {
bytes = -EFAULT;
goto out;
}
bytes = efivar_entry_set_get_size(var, attributes, &datasize,
data, &set);
if (!set && bytes) {
if (bytes == -ENOENT)
bytes = -EIO;
goto out;
}
if (bytes == -ENOENT) {
drop_nlink(inode);
d_delete(file->f_dentry);
dput(file->f_dentry);
} else {
mutex_lock(&inode->i_mutex);
i_size_write(inode, datasize + sizeof(attributes));
mutex_unlock(&inode->i_mutex);
}
bytes = count;
out:
kfree(data);
return bytes;
}
示例4: efivarfs_unlink
static int efivarfs_unlink(struct inode *dir, struct dentry *dentry)
{
struct efivar_entry *var = dentry->d_inode->i_private;
if (efivar_entry_delete(var))
return -EINVAL;
drop_nlink(dentry->d_inode);
dput(dentry);
return 0;
};
示例5: sysfs_drop_dentry
/**
* sysfs_drop_dentry - drop dentry for the specified sysfs_dirent
* @sd: target sysfs_dirent
*
* Drop dentry for @sd. @sd must have been unlinked from its
* parent on entry to this function such that it can't be looked
* up anymore.
*
* @sd->s_dentry which is protected with sysfs_assoc_lock points
* to the currently associated dentry but we're not holding a
* reference to it and racing with dput(). Grab dcache_lock and
* verify dentry before dropping it. If @sd->s_dentry is NULL or
* dput() beats us, no need to bother.
*/
static void sysfs_drop_dentry(struct sysfs_dirent *sd)
{
struct dentry *dentry = NULL;
struct inode *inode;
/* We're not holding a reference to ->s_dentry dentry but the
* field will stay valid as long as sysfs_assoc_lock is held.
*/
spin_lock(&sysfs_assoc_lock);
spin_lock(&dcache_lock);
/* drop dentry if it's there and dput() didn't kill it yet */
if (sd->s_dentry && sd->s_dentry->d_inode) {
dentry = dget_locked(sd->s_dentry);
spin_lock(&dentry->d_lock);
__d_drop(dentry);
spin_unlock(&dentry->d_lock);
}
spin_unlock(&dcache_lock);
spin_unlock(&sysfs_assoc_lock);
/* dentries for shadowed inodes are pinned, unpin */
if (dentry && sysfs_is_shadowed_inode(dentry->d_inode))
dput(dentry);
dput(dentry);
/* adjust nlink and update timestamp */
inode = ilookup(sysfs_sb, sd->s_ino);
if (inode) {
mutex_lock(&inode->i_mutex);
inode->i_ctime = CURRENT_TIME;
drop_nlink(inode);
if (sysfs_type(sd) == SYSFS_DIR)
drop_nlink(inode);
mutex_unlock(&inode->i_mutex);
iput(inode);
}
}
示例6: hfsplus_unlink
static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
{
struct super_block *sb = dir->i_sb;
struct inode *inode = dentry->d_inode;
struct qstr str;
char name[32];
u32 cnid;
int res;
if (HFSPLUS_IS_RSRC(inode))
return -EPERM;
cnid = (u32)(unsigned long)dentry->d_fsdata;
if (inode->i_ino == cnid &&
atomic_read(&HFSPLUS_I(inode).opencnt)) {
str.name = name;
str.len = sprintf(name, "temp%lu", inode->i_ino);
res = hfsplus_rename_cat(inode->i_ino,
dir, &dentry->d_name,
HFSPLUS_SB(sb).hidden_dir, &str);
if (!res)
inode->i_flags |= S_DEAD;
return res;
}
res = hfsplus_delete_cat(cnid, dir, &dentry->d_name);
if (res)
return res;
if (inode->i_nlink > 0)
drop_nlink(inode);
if (inode->i_ino == cnid)
clear_nlink(inode);
if (!inode->i_nlink) {
if (inode->i_ino != cnid) {
HFSPLUS_SB(sb).file_count--;
if (!atomic_read(&HFSPLUS_I(inode).opencnt)) {
res = hfsplus_delete_cat(inode->i_ino,
HFSPLUS_SB(sb).hidden_dir,
NULL);
if (!res)
hfsplus_delete_inode(inode);
} else
inode->i_flags |= S_DEAD;
} else
hfsplus_delete_inode(inode);
} else
HFSPLUS_SB(sb).file_count--;
inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
return res;
}
示例7: sysfs_remove_one
/**
* sysfs_remove_one - remove sysfs_dirent from parent
* @acxt: addrm context to use
* @sd: sysfs_dirent to be added
*
* Mark @sd removed and drop nlink of parent inode if @sd is a
* directory. @sd is NOT unlinked from the children list of the
* parent. The caller is repsonsible for removing @sd from the
* children list before calling this function.
*
* This function should be called between calls to
* sysfs_addrm_start() and sysfs_addrm_finish() and should be
* passed the same @acxt as passed to sysfs_addrm_start().
*
* LOCKING:
* Determined by sysfs_addrm_start().
*/
void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
{
BUG_ON(sd->s_sibling || (sd->s_flags & SYSFS_FLAG_REMOVED));
sd->s_flags |= SYSFS_FLAG_REMOVED;
sd->s_sibling = acxt->removed;
acxt->removed = sd;
if (sysfs_type(sd) == SYSFS_DIR && acxt->parent_inode)
drop_nlink(acxt->parent_inode);
acxt->cnt++;
}
示例8: coda_unlink
/* destruction routines: unlink, rmdir */
static int coda_unlink(struct inode *dir, struct dentry *de)
{
int error;
const char *name = de->d_name.name;
int len = de->d_name.len;
error = venus_remove(dir->i_sb, coda_i2f(dir), name, len);
if (error)
return error;
coda_dir_update_mtime(dir);
drop_nlink(de->d_inode);
return 0;
}
示例9: nilfs_symlink
static int nilfs_symlink(struct inode *dir, struct dentry *dentry,
const char *symname)
{
struct nilfs_transaction_info ti;
struct super_block *sb = dir->i_sb;
unsigned int l = strlen(symname) + 1;
struct inode *inode;
int err;
if (l > sb->s_blocksize)
return -ENAMETOOLONG;
err = nilfs_transaction_begin(dir->i_sb, &ti, 1);
if (err)
return err;
inode = nilfs_new_inode(dir, S_IFLNK | S_IRWXUGO);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out;
/* slow symlink */
inode->i_op = &nilfs_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &nilfs_aops;
err = page_symlink(inode, symname, l);
if (err)
goto out_fail;
/* mark_inode_dirty(inode); */
/* page_symlink() do this */
err = nilfs_add_nondir(dentry, inode);
out:
if (!err)
err = nilfs_transaction_commit(dir->i_sb);
else
nilfs_transaction_abort(dir->i_sb);
return err;
out_fail:
drop_nlink(inode);
nilfs_mark_inode_dirty(inode);
unlock_new_inode(inode);
iput(inode);
goto out;
}
示例10: yramfs_dir_unlink
int yramfs_dir_unlink(struct inode *dir, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
int err;
DBG_PRINT("unlink for %s", dentry->d_name.name);
inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
err = yramfs_dir_remove_path(dir, dentry);
if (err) {
DBG_PRINT("remove path failed:%d", err);
}
drop_nlink(inode);
dput(dentry);
return 0;
}
示例11: hfs_unlink
/*
* hfs_unlink()
*
* This is the unlink() entry in the inode_operations structure for
* regular HFS directories. The purpose is to delete an existing
* file, given the inode for the parent directory and the name
* (and its length) of the existing file.
*/
static int hfs_unlink(struct inode *dir, struct dentry *dentry)
{
struct inode *inode;
int res;
inode = dentry->d_inode;
res = hfs_cat_delete(inode->i_ino, dir, &dentry->d_name);
if (res)
return res;
drop_nlink(inode);
hfs_delete_inode(inode);
inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode);
return res;
}
示例12: pmfs_unlink
static int pmfs_unlink(struct inode *dir, struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
struct super_block *sb = dir->i_sb;
int retval = -ENOMEM;
struct pmfs_inode *pi = pmfs_get_inode(sb, inode);
struct pmfs_inode *pidir;
u64 pidir_tail = 0, pi_tail = 0;
int invalidate = 0;
timing_t unlink_time;
PMFS_START_TIMING(unlink_t, unlink_time);
pidir = pmfs_get_inode(sb, dir);
if (!pidir)
goto out;
pmfs_dbgv("%s: %s, ino %lu, dir %lu\n", __func__,
dentry->d_name.name, inode->i_ino, dir->i_ino);
retval = pmfs_remove_entry(dentry, 0, 0, &pidir_tail);
if (retval)
goto out;
inode->i_ctime = dir->i_ctime;
if (inode->i_nlink == 1)
invalidate = 1;
if (inode->i_nlink) {
drop_nlink(inode);
}
retval = pmfs_append_link_change_entry(sb, pi, inode, 0, &pi_tail);
if (retval)
goto out;
pmfs_lite_transaction_for_time_and_link(sb, pi, pidir,
pi_tail, pidir_tail, invalidate);
PMFS_END_TIMING(unlink_t, unlink_time);
return 0;
out:
pmfs_err(sb, "%s return %d\n", __func__, retval);
PMFS_END_TIMING(unlink_t, unlink_time);
return retval;
}
示例13: au_do_hide
static void au_do_hide(struct dentry *dentry)
{
struct inode *inode;
inode = dentry->d_inode;
if (inode) {
if (!S_ISDIR(inode->i_mode)) {
if (inode->i_nlink && !d_unhashed(dentry))
drop_nlink(inode);
} else {
clear_nlink(inode);
/* stop next lookup */
inode->i_flags |= S_DEAD;
}
smp_mb(); /* necessary? */
}
d_drop(dentry);
}
示例14: au_do_hide
static void au_do_hide(struct dentry *dentry)
{
struct inode *inode;
if (d_really_is_positive(dentry)) {
inode = d_inode(dentry);
if (!d_is_dir(dentry)) {
if (inode->i_nlink && !d_unhashed(dentry))
drop_nlink(inode);
} else {
clear_nlink(inode);
/* stop next lookup */
inode->i_flags |= S_DEAD;
}
smp_mb(); /* necessary? */
}
d_drop(dentry);
}
示例15: devpts_pty_kill
/**
* devpts_pty_kill -- remove inode form /dev/pts/
* @inode: inode of the slave to be removed
*
* This is an inverse operation of devpts_pty_new.
*/
void devpts_pty_kill(struct inode *inode)
{
struct super_block *sb = pts_sb_from_inode(inode);
struct dentry *root = sb->s_root;
struct dentry *dentry;
BUG_ON(inode->i_rdev == MKDEV(TTYAUX_MAJOR, PTMX_MINOR));
mutex_lock(&root->d_inode->i_mutex);
dentry = d_find_alias(inode);
drop_nlink(inode);
d_delete(dentry);
dput(dentry); /* d_alloc_name() in devpts_pty_new() */
dput(dentry); /* d_find_alias above */
mutex_unlock(&root->d_inode->i_mutex);
}