本文整理汇总了C++中set_nlink函数的典型用法代码示例。如果您正苦于以下问题:C++ set_nlink函数的具体用法?C++ set_nlink怎么用?C++ set_nlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_nlink函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ecryptfs_rmdir
static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
{
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
int rc;
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;
}
开发者ID:garyvan,项目名称:openwrt-1.6,代码行数:22,代码来源:inode.c
示例2: wrapfs_rmdir
static int wrapfs_rmdir(struct inode *dir, struct dentry *dentry)
{
struct dentry *lower_dentry;
struct dentry *lower_dir_dentry;
int err;
struct path lower_path;
if(wrapfs_get_debug(dir->i_sb) & DEBUG_INODE)
DEBUG_MESG("Enter");
wrapfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
lower_dir_dentry = lock_parent(lower_dentry);
err = mnt_want_write(lower_path.mnt);
if (err)
goto out_unlock;
err = vfs_rmdir(lower_dir_dentry->d_inode, lower_dentry);
if (err)
goto out;
d_drop(dentry); /* drop our dentry on success (why not VFS's job?) */
if (dentry->d_inode)
clear_nlink(dentry->d_inode);
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:
mnt_drop_write(lower_path.mnt);
out_unlock:
unlock_dir(lower_dir_dentry);
wrapfs_put_lower_path(dentry, &lower_path);
if(wrapfs_get_debug(dir->i_sb) & DEBUG_INODE)
DEBUG_RETURN("Exit", err);
return err;
}
开发者ID:weixu8,项目名称:EncryptedFilesystem,代码行数:39,代码来源:inode.c
示例3: diaryfs_unlink
static int diaryfs_unlink(struct inode *dir, struct dentry *dentry) {
int err;
struct dentry * lower_dentry;
struct inode * lower_dir_inode = diaryfs_lower_inode(dir);
struct dentry * lower_dir_dentry;
struct path lower_path;
diaryfs_get_lower_path(dentry, &lower_path);
lower_dentry = lower_path.dentry;
dget(lower_dentry);
lower_dir_dentry = lock_parent(lower_dentry);
err = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
/*
* Note: unlinking on top of NFS can cause silly-renamed files
* Trying to delete such files results in EBUSY from NFS
* below. Silly-renamed files will get deleted by NFS later on,
* so we just need to detect them here and treat EBUSY errors
* as if the upper file was successfully deleted.
*/
if (err == -EBUSY && lower_dentry->d_flags & DCACHE_NFSFS_RENAMED)
err = 0;
if (err)
goto out;
fsstack_copy_attr_times(dir, lower_dir_inode);
fsstack_copy_inode_size(dir, lower_dir_inode);
set_nlink(dentry->d_inode, diaryfs_lower_inode(dentry->d_inode)->i_nlink);
dentry->d_inode->i_ctime = dir->i_ctime;
d_drop(dentry); /* this is needed, else LTP fails */
out:
unlock_dir(lower_dir_dentry);
dput(lower_dentry);
diaryfs_put_lower_path(dentry, &lower_path);
return err;
}
开发者ID:jameswhang,项目名称:DiaryFS,代码行数:39,代码来源:inode.c
示例4: ccfs_link
static int ccfs_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *new_dentry)
{
struct dentry *lower_old_dentry;
struct dentry *lower_new_dentry;
struct dentry *lower_dir_dentry;
u64 file_size_save;
int rc;
// TODO: Update cached link
file_size_save = i_size_read(old_dentry->d_inode);
lower_old_dentry = ccfs_get_nested_dentry(old_dentry);
lower_new_dentry = ccfs_get_nested_dentry(new_dentry);
dget(lower_old_dentry);
dget(lower_new_dentry);
mdbg(INFO3,"Link w/ lower_dentry->d_name.name = [%s] Link = [%s]", lower_old_dentry->d_name.name, lower_new_dentry->d_name.name);
lower_dir_dentry = lock_parent(lower_new_dentry);
rc = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
lower_new_dentry);
if (rc || !lower_new_dentry->d_inode)
goto out_lock;
rc = ccfs_interpose(lower_new_dentry, new_dentry, dir->i_sb, 0);
if (rc)
goto out_lock;
fsstack_copy_attr_times(dir, lower_new_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_new_dentry->d_inode);
set_nlink(old_dentry->d_inode, ccfs_get_nested_inode(old_dentry->d_inode)->i_nlink); //Fix for kernel 3.7.1 use function set_nlink by Jiri Rakosnik
i_size_write(new_dentry->d_inode, file_size_save);
out_lock:
unlock_dir(lower_dir_dentry);
dput(lower_new_dentry);
dput(lower_old_dentry);
d_drop(lower_old_dentry);
d_drop(new_dentry);
d_drop(old_dentry);
return rc;
}
开发者ID:FIT-CVUT,项目名称:clondike,代码行数:38,代码来源:inode.c
示例5: scfs_mkdir
/*
* scfs_mkdir
*
* Parameters:
* @*dir: inode of the dir to create
* @*scfs_dentry: dentry of the dir to create
* @mode:
*
* Return:
* SCFS_SUCCESS if success, otherwise if error
*
* Description:
* mkdir() for SCFS.
*/
static int scfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
struct dentry *lower_dir_dentry;
struct dentry *lower_parent_dentry;
int ret;
lower_dir_dentry = scfs_lower_dentry(dentry);
lower_parent_dentry = lock_parent(lower_dir_dentry);
ret = vfs_mkdir(lower_parent_dentry->d_inode, lower_dir_dentry, mode);
if (ret || !lower_dir_dentry->d_inode) {
SCFS_PRINT_ERROR("dir %s vfs_mkdir failed, "
"lower_dir %s lower_parent %s mode %x\n",
dentry->d_name.name,
lower_dir_dentry->d_name.name,
lower_parent_dentry->d_name.name, mode);
goto out;
}
ret = scfs_interpose(lower_dir_dentry, dentry, dir->i_sb);
if (ret) {
SCFS_PRINT_ERROR("dir %s interpose failed, "
"lower_dir %s lower_parent %s mode %x\n",
dentry->d_name.name,
lower_dir_dentry->d_name.name,
lower_parent_dentry->d_name.name, mode);
vfs_rmdir(lower_parent_dentry->d_inode, lower_dir_dentry);
goto out;
}
fsstack_copy_attr_times(dir, lower_parent_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_parent_dentry->d_inode);
set_nlink(dir, lower_parent_dentry->d_inode->i_nlink);
out:
unlock_dir(lower_parent_dentry);
if (!dentry->d_inode)
d_drop(dentry);
return ret;
}
开发者ID:sombree,项目名称:Hulk-Kernel-V2,代码行数:52,代码来源:inode.c
示例6: fuse_change_attributes_common
void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
u64 attr_valid)
{
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode);
fi->attr_version = ++fc->attr_version;
fi->i_time = attr_valid;
inode->i_ino = fuse_squash_ino(attr->ino);
inode->i_mode = (inode->i_mode & S_IFMT) | (attr->mode & 07777);
set_nlink(inode, attr->nlink);
inode->i_uid = make_kuid(&init_user_ns, attr->uid);
inode->i_gid = make_kgid(&init_user_ns, attr->gid);
inode->i_blocks = attr->blocks;
inode->i_atime.tv_sec = attr->atime;
inode->i_atime.tv_nsec = attr->atimensec;
inode->i_mtime.tv_sec = attr->mtime;
inode->i_mtime.tv_nsec = attr->mtimensec;
inode->i_ctime.tv_sec = attr->ctime;
inode->i_ctime.tv_nsec = attr->ctimensec;
if (attr->blksize != 0)
inode->i_blkbits = ilog2(attr->blksize);
else
inode->i_blkbits = inode->i_sb->s_blocksize_bits;
/*
* Don't set the sticky bit in i_mode, unless we want the VFS
* to check permissions. This prevents failures due to the
* check in may_delete().
*/
fi->orig_i_mode = inode->i_mode;
if (!(fc->flags & FUSE_DEFAULT_PERMISSIONS))
inode->i_mode &= ~S_ISVTX;
fi->orig_ino = attr->ino;
}
开发者ID:Jlsmily,项目名称:android_kernel_meilan2,代码行数:38,代码来源:inode.c
示例7: zfs_inode_update
/*
* Update the embedded inode given the znode. We should work toward
* eliminating this function as soon as possible by removing values
* which are duplicated between the znode and inode. If the generic
* inode has the correct field it should be used, and the ZFS code
* updated to access the inode. This can be done incrementally.
*/
void
zfs_inode_update(znode_t *zp)
{
zfs_sb_t *zsb;
struct inode *ip;
uint32_t blksize;
uint64_t atime[2], mtime[2], ctime[2];
ASSERT(zp != NULL);
zsb = ZTOZSB(zp);
ip = ZTOI(zp);
/* Skip .zfs control nodes which do not exist on disk. */
if (zfsctl_is_node(ip))
return;
sa_lookup(zp->z_sa_hdl, SA_ZPL_ATIME(zsb), &atime, 16);
sa_lookup(zp->z_sa_hdl, SA_ZPL_MTIME(zsb), &mtime, 16);
sa_lookup(zp->z_sa_hdl, SA_ZPL_CTIME(zsb), &ctime, 16);
spin_lock(&ip->i_lock);
ip->i_generation = zp->z_gen;
ip->i_uid = SUID_TO_KUID(zp->z_uid);
ip->i_gid = SGID_TO_KGID(zp->z_gid);
set_nlink(ip, zp->z_links);
ip->i_mode = zp->z_mode;
zfs_set_inode_flags(zp, ip);
ip->i_blkbits = SPA_MINBLOCKSHIFT;
dmu_object_size_from_db(sa_get_db(zp->z_sa_hdl), &blksize,
(u_longlong_t *)&ip->i_blocks);
ZFS_TIME_DECODE(&ip->i_atime, atime);
ZFS_TIME_DECODE(&ip->i_mtime, mtime);
ZFS_TIME_DECODE(&ip->i_ctime, ctime);
i_size_write(ip, zp->z_size);
spin_unlock(&ip->i_lock);
}
开发者ID:carriercomm,项目名称:zfs-crypto,代码行数:45,代码来源:zfs_znode.c
示例8: au_cpup_attr_nlink
void au_cpup_attr_nlink(struct inode *inode, int force)
{
struct inode *h_inode;
struct super_block *sb;
aufs_bindex_t bindex, bend;
sb = inode->i_sb;
bindex = au_ibstart(inode);
h_inode = au_h_iptr(inode, bindex);
if (!force
&& !S_ISDIR(h_inode->i_mode)
&& au_opt_test(au_mntflags(sb), PLINK)
&& au_plink_test(inode))
return;
/*
* 0 can happen in revalidating.
* h_inode->i_mutex may not be held here, but it is harmless since once
* i_nlink reaches 0, it will never become positive except O_TMPFILE
* case.
* todo: O_TMPFILE+linkat(AT_SYMLINK_FOLLOW) bypassing aufs may cause
* the incorrect link count.
*/
set_nlink(inode, h_inode->i_nlink);
/*
* fewer nlink makes find(1) noisy, but larger nlink doesn't.
* it may includes whplink directory.
*/
if (S_ISDIR(h_inode->i_mode)) {
bend = au_ibend(inode);
for (bindex++; bindex <= bend; bindex++) {
h_inode = au_h_iptr(inode, bindex);
if (h_inode)
au_add_nlink(inode, h_inode);
}
}
}
开发者ID:ammubhave,项目名称:bargud,代码行数:38,代码来源:cpup.c
示例9: 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;
}
开发者ID:Vagelis1608,项目名称:-V-_Kernel_2,代码行数:23,代码来源:inode.c
示例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;
}
开发者ID:sombree,项目名称:Hulk-Kernel-V2,代码行数:23,代码来源:inode.c
示例11: ovl_dentry_lower
struct inode *ovl_get_inode(struct dentry *dentry, struct dentry *upperdentry)
{
struct dentry *lowerdentry = ovl_dentry_lower(dentry);
struct inode *realinode = upperdentry ? d_inode(upperdentry) : NULL;
struct inode *inode;
if (!realinode)
realinode = d_inode(lowerdentry);
if (!S_ISDIR(realinode->i_mode) &&
(upperdentry || (lowerdentry && ovl_indexdir(dentry->d_sb)))) {
struct inode *key = d_inode(lowerdentry ?: upperdentry);
unsigned int nlink;
inode = iget5_locked(dentry->d_sb, (unsigned long) key,
ovl_inode_test, ovl_inode_set, key);
if (!inode)
goto out_nomem;
if (!(inode->i_state & I_NEW)) {
/*
* Verify that the underlying files stored in the inode
* match those in the dentry.
*/
if (!ovl_verify_inode(inode, lowerdentry, upperdentry)) {
iput(inode);
inode = ERR_PTR(-ESTALE);
goto out;
}
dput(upperdentry);
goto out;
}
nlink = ovl_get_nlink(lowerdentry, upperdentry,
realinode->i_nlink);
set_nlink(inode, nlink);
} else {
开发者ID:mkrufky,项目名称:linux,代码行数:37,代码来源:inode.c
示例12: 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;
}
开发者ID:Vagelis1608,项目名称:-V-_Kernel_2,代码行数:24,代码来源:inode.c
示例13: devpts_fill_super
static int
devpts_fill_super(struct super_block *s, void *data, int silent)
{
struct inode *inode;
s->s_blocksize = 1024;
s->s_blocksize_bits = 10;
s->s_magic = DEVPTS_SUPER_MAGIC;
s->s_op = &devpts_sops;
s->s_time_gran = 1;
s->s_fs_info = new_pts_fs_info();
if (!s->s_fs_info)
goto fail;
inode = new_inode(s);
if (!inode)
goto free_fsi;
inode->i_ino = 1;
inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO | S_IWUSR;
inode->i_op = &simple_dir_inode_operations;
inode->i_fop = &simple_dir_operations;
set_nlink(inode, 2);
s->s_root = d_make_root(inode);
if (s->s_root)
return 0;
printk(KERN_ERR "devpts: get root dentry failed\n");
free_fsi:
kfree(s->s_fs_info);
fail:
return -ENOMEM;
}
开发者ID:nos1609,项目名称:Chrono_Kernel-1,代码行数:36,代码来源:inode.c
示例14: wrapfs_link
static int wrapfs_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *new_dentry)
{
struct dentry *lower_old_dentry;
struct dentry *lower_new_dentry;
struct dentry *lower_dir_dentry;
u64 file_size_save;
int err;
struct path lower_old_path, lower_new_path;
file_size_save = i_size_read(old_dentry->d_inode);
wrapfs_get_lower_path(old_dentry, &lower_old_path);
wrapfs_get_lower_path(new_dentry, &lower_new_path);
lower_old_dentry = lower_old_path.dentry;
lower_new_dentry = lower_new_path.dentry;
lower_dir_dentry = lock_parent(lower_new_dentry);
err = vfs_link(lower_old_dentry, lower_dir_dentry->d_inode,
lower_new_dentry, NULL);
if (err || !lower_new_dentry->d_inode)
goto out;
err = wrapfs_interpose(new_dentry, dir->i_sb, &lower_new_path);
if (err)
goto out;
fsstack_copy_attr_times(dir, lower_new_dentry->d_inode);
fsstack_copy_inode_size(dir, lower_new_dentry->d_inode);
set_nlink(old_dentry->d_inode,
wrapfs_lower_inode(old_dentry->d_inode)->i_nlink);
i_size_write(new_dentry->d_inode, file_size_save);
out:
unlock_dir(lower_dir_dentry);
wrapfs_put_lower_path(old_dentry, &lower_old_path);
wrapfs_put_lower_path(new_dentry, &lower_new_path);
return err;
}
开发者ID:DEEKSHA26SHARMA,项目名称:wrapfs-nektech,代码行数:36,代码来源:inode.c
示例15: vxfs_iinit
/**
* vxfs_iinit- helper to fill inode fields
* @ip: VFS inode
* @vip: VxFS inode
*
* Description:
* vxfs_instino is a helper function to fill in all relevant
* fields in @ip from @vip.
*/
static void
vxfs_iinit(struct inode *ip, struct vxfs_inode_info *vip)
{
ip->i_mode = vxfs_transmod(vip);
ip->i_uid = (uid_t)vip->vii_uid;
ip->i_gid = (gid_t)vip->vii_gid;
set_nlink(ip, vip->vii_nlink);
ip->i_size = vip->vii_size;
ip->i_atime.tv_sec = vip->vii_atime;
ip->i_ctime.tv_sec = vip->vii_ctime;
ip->i_mtime.tv_sec = vip->vii_mtime;
ip->i_atime.tv_nsec = 0;
ip->i_ctime.tv_nsec = 0;
ip->i_mtime.tv_nsec = 0;
ip->i_blocks = vip->vii_blocks;
ip->i_generation = vip->vii_gen;
ip->i_private = vip;
}
开发者ID:ARMWorks,项目名称:FA_2451_Linux_Kernel,代码行数:33,代码来源:vxfs_inode.c
示例16: swap_inode_boot_loader
/**
* Swap the information from the given @inode and the inode
* EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other
* important fields of the inodes.
*
* @sb: the super block of the filesystem
* @inode: the inode to swap with EXT4_BOOT_LOADER_INO
*
*/
static long swap_inode_boot_loader(struct super_block *sb,
struct inode *inode)
{
handle_t *handle;
int err;
struct inode *inode_bl;
struct ext4_inode_info *ei_bl;
struct ext4_sb_info *sbi = EXT4_SB(sb);
if (inode->i_nlink != 1 || !S_ISREG(inode->i_mode)) {
err = -EINVAL;
goto swap_boot_out;
}
if (!inode_owner_or_capable(inode) || !capable(CAP_SYS_ADMIN)) {
err = -EPERM;
goto swap_boot_out;
}
inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO);
if (IS_ERR(inode_bl)) {
err = PTR_ERR(inode_bl);
goto swap_boot_out;
}
ei_bl = EXT4_I(inode_bl);
filemap_flush(inode->i_mapping);
filemap_flush(inode_bl->i_mapping);
/* Protect orig inodes against a truncate and make sure,
* that only 1 swap_inode_boot_loader is running. */
lock_two_nondirectories(inode, inode_bl);
truncate_inode_pages(&inode->i_data, 0);
truncate_inode_pages(&inode_bl->i_data, 0);
/* Wait for all existing dio workers */
ext4_inode_block_unlocked_dio(inode);
ext4_inode_block_unlocked_dio(inode_bl);
inode_dio_wait(inode);
inode_dio_wait(inode_bl);
handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2);
if (IS_ERR(handle)) {
err = -EINVAL;
goto journal_err_out;
}
/* Protect extent tree against block allocations via delalloc */
ext4_double_down_write_data_sem(inode, inode_bl);
if (inode_bl->i_nlink == 0) {
/* this inode has never been used as a BOOT_LOADER */
set_nlink(inode_bl, 1);
i_uid_write(inode_bl, 0);
i_gid_write(inode_bl, 0);
inode_bl->i_flags = 0;
ei_bl->i_flags = 0;
inode_bl->i_version = 1;
i_size_write(inode_bl, 0);
inode_bl->i_mode = S_IFREG;
if (EXT4_HAS_INCOMPAT_FEATURE(sb,
EXT4_FEATURE_INCOMPAT_EXTENTS)) {
ext4_set_inode_flag(inode_bl, EXT4_INODE_EXTENTS);
ext4_ext_tree_init(handle, inode_bl);
} else
memset(ei_bl->i_data, 0, sizeof(ei_bl->i_data));
}
swap_inode_data(inode, inode_bl);
inode->i_ctime = inode_bl->i_ctime = ext4_current_time(inode);
spin_lock(&sbi->s_next_gen_lock);
inode->i_generation = sbi->s_next_generation++;
inode_bl->i_generation = sbi->s_next_generation++;
spin_unlock(&sbi->s_next_gen_lock);
ext4_discard_preallocations(inode);
err = ext4_mark_inode_dirty(handle, inode);
if (err < 0) {
ext4_warning(inode->i_sb,
"couldn't mark inode #%lu dirty (err %d)",
inode->i_ino, err);
/* Revert all changes: */
swap_inode_data(inode, inode_bl);
} else {
err = ext4_mark_inode_dirty(handle, inode_bl);
if (err < 0) {
ext4_warning(inode_bl->i_sb,
//.........这里部分代码省略.........
开发者ID:acorn-marvell,项目名称:brillo_pxa_kernel,代码行数:101,代码来源:ioctl.c
示例17: parse_rock_ridge_inode_internal
static int
parse_rock_ridge_inode_internal(struct iso_directory_record *de,
struct inode *inode, int regard_xa)
{
int symlink_len = 0;
int cnt, sig;
struct inode *reloc;
struct rock_ridge *rr;
int rootflag;
struct rock_state rs;
int ret = 0;
if (!ISOFS_SB(inode->i_sb)->s_rock)
return 0;
init_rock_state(&rs, inode);
setup_rock_ridge(de, inode, &rs);
if (regard_xa) {
rs.chr += 14;
rs.len -= 14;
if (rs.len < 0)
rs.len = 0;
}
repeat:
while (rs.len > 2) { /* There may be one byte for padding somewhere */
rr = (struct rock_ridge *)rs.chr;
/*
* Ignore rock ridge info if rr->len is out of range, but
* don't return -EIO because that would make the file
* invisible.
*/
if (rr->len < 3)
goto out; /* Something got screwed up here */
sig = isonum_721(rs.chr);
if (rock_check_overflow(&rs, sig))
goto eio;
rs.chr += rr->len;
rs.len -= rr->len;
/*
* As above, just ignore the rock ridge info if rr->len
* is bogus.
*/
if (rs.len < 0)
goto out; /* Something got screwed up here */
switch (sig) {
#ifndef CONFIG_ZISOFS /* No flag for SF or ZF */
case SIG('R', 'R'):
if ((rr->u.RR.flags[0] &
(RR_PX | RR_TF | RR_SL | RR_CL)) == 0)
goto out;
break;
#endif
case SIG('S', 'P'):
if (check_sp(rr, inode))
goto out;
break;
case SIG('C', 'E'):
rs.cont_extent = isonum_733(rr->u.CE.extent);
rs.cont_offset = isonum_733(rr->u.CE.offset);
rs.cont_size = isonum_733(rr->u.CE.size);
break;
case SIG('E', 'R'):
ISOFS_SB(inode->i_sb)->s_rock = 1;
printk(KERN_DEBUG "ISO 9660 Extensions: ");
{
int p;
for (p = 0; p < rr->u.ER.len_id; p++)
printk("%c", rr->u.ER.data[p]);
}
printk("\n");
break;
case SIG('P', 'X'):
inode->i_mode = isonum_733(rr->u.PX.mode);
set_nlink(inode, isonum_733(rr->u.PX.n_links));
inode->i_uid = isonum_733(rr->u.PX.uid);
inode->i_gid = isonum_733(rr->u.PX.gid);
break;
case SIG('P', 'N'):
{
int high, low;
high = isonum_733(rr->u.PN.dev_high);
low = isonum_733(rr->u.PN.dev_low);
/*
* The Rock Ridge standard specifies that if
* sizeof(dev_t) <= 4, then the high field is
* unused, and the device number is completely
* stored in the low field. Some writers may
* ignore this subtlety,
* and as a result we test to see if the entire
* device number is
* stored in the low field, and use that.
*/
if ((low & ~0xff) && high == 0) {
inode->i_rdev =
MKDEV(low >> 8, low & 0xff);
} else {
inode->i_rdev =
MKDEV(high, low);
//.........这里部分代码省略.........
开发者ID:openube,项目名称:android_kernel_sony_c2305,代码行数:101,代码来源:rock.c
示例18: xfs_setup_inode
/*
* Initialize the Linux inode, set up the operation vectors and
* unlock the inode.
*
* When reading existing inodes from disk this is called directly
* from xfs_iget, when creating a new inode it is called from
* xfs_ialloc after setting up the inode.
*
* We are always called with an uninitialised linux inode here.
* We need to initialise the necessary fields and take a reference
* on it.
*/
void
xfs_setup_inode(
struct xfs_inode *ip)
{
struct inode *inode = &ip->i_vnode;
gfp_t gfp_mask;
inode->i_ino = ip->i_ino;
inode->i_state = I_NEW;
inode_sb_list_add(inode);
/* make the inode look hashed for the writeback code */
hlist_add_fake(&inode->i_hash);
inode->i_mode = ip->i_d.di_mode;
set_nlink(inode, ip->i_d.di_nlink);
inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid);
inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid);
switch (inode->i_mode & S_IFMT) {
case S_IFBLK:
case S_IFCHR:
inode->i_rdev =
MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
sysv_minor(ip->i_df.if_u2.if_rdev));
break;
default:
inode->i_rdev = 0;
break;
}
inode->i_generation = ip->i_d.di_gen;
i_size_write(inode, ip->i_d.di_size);
inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
xfs_diflags_to_iflags(inode, ip);
ip->d_ops = ip->i_mount->m_nondir_inode_ops;
lockdep_set_class(&ip->i_lock.mr_lock, &xfs_nondir_ilock_class);
switch (inode->i_mode & S_IFMT) {
case S_IFREG:
inode->i_op = &xfs_inode_operations;
inode->i_fop = &xfs_file_operations;
inode->i_mapping->a_ops = &xfs_address_space_operations;
break;
case S_IFDIR:
lockdep_set_class(&ip->i_lock.mr_lock, &xfs_dir_ilock_class);
if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
inode->i_op = &xfs_dir_ci_inode_operations;
else
inode->i_op = &xfs_dir_inode_operations;
inode->i_fop = &xfs_dir_file_operations;
ip->d_ops = ip->i_mount->m_dir_inode_ops;
break;
case S_IFLNK:
inode->i_op = &xfs_symlink_inode_operations;
if (!(ip->i_df.if_flags & XFS_IFINLINE))
inode->i_mapping->a_ops = &xfs_address_space_operations;
break;
default:
inode->i_op = &xfs_inode_operations;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
break;
}
/*
* Ensure all page cache allocations are done from GFP_NOFS context to
* prevent direct reclaim recursion back into the filesystem and blowing
* stacks or deadlocking.
*/
gfp_mask = mapping_gfp_mask(inode->i_mapping);
mapping_set_gfp_mask(inode->i_mapping, (gfp_mask & ~(__GFP_FS)));
/*
* If there is no attribute fork no ACL can exist on this inode,
* and it can't have any file capabilities attached to it either.
*/
if (!XFS_IFORK_Q(ip)) {
inode_has_no_xattr(inode);
cache_no_acl(inode);
}
xfs_iflags_clear(ip, XFS_INEW);
barrier();
//.........这里部分代码省略.........
开发者ID:luyanseu,项目名称:linux,代码行数:101,代码来源:xfs_iops.c
示例19: ubifs_link
//.........这里部分代码省略.........
if (err)
return err;
err = ubifs_budget_space(c, &req);
if (err) {
if (err != -ENOSPC)
return err;
budgeted = 0;
}
lock_2_inodes(dir, inode);
inode->i_ctime = ubifs_current_time(dir);
drop_nlink(inode);
dir->i_size -= sz_change;
dir_ui->ui_size = dir->i_size;
dir->i_mtime = dir->i_ctime = inode->i_ctime;
err = ubifs_jnl_update(c, dir, &dentry->d_name, inode, 1, 0);
if (err)
goto out_cancel;
unlock_2_inodes(dir, inode);
if (budgeted)
ubifs_release_budget(c, &req);
else {
/* We've deleted something - clean the "no space" flags */
c->bi.nospace = c->bi.nospace_rp = 0;
smp_wmb();
}
return 0;
out_cancel:
dir->i_size += sz_change;
dir_ui->ui_size = dir->i_size;
set_nlink(inode, saved_nlink);
unlock_2_inodes(dir, inode);
if (budgeted)
ubifs_release_budget(c, &req);
return err;
}
/**
* check_dir_empty - check if a directory is empty or not.
* @c: UBIFS file-system description object
* @dir: VFS inode object of the directory to check
*
* This function checks if directory @dir is empty. Returns zero if the
* directory is empty, %-ENOTEMPTY if it is not, and other negative error codes
* in case of of errors.
*/
static int check_dir_empty(struct ubifs_info *c, struct inode *dir)
{
struct qstr nm = { .name = NULL };
struct ubifs_dent_node *dent;
union ubifs_key key;
int err;
lowest_dent_key(c, &key, dir->i_ino);
dent = ubifs_tnc_next_ent(c, &key, &nm);
if (IS_ERR(dent)) {
err = PTR_ERR(dent);
if (err == -ENOENT)
err = 0;
} else {
kfree(dent);
err = -ENOTEMPTY;
}
开发者ID:DenisLug,项目名称:mptcp,代码行数:67,代码来源:dir.c
示例20: unionfs_mknod
static int unionfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
dev_t dev)
{
int err = 0;
struct dentry *lower_dentry = NULL;
struct dentry *wh_dentry = NULL;
struct dentry *lower_parent_dentry = NULL;
struct dentry *parent;
char *name = NULL;
int valid = 0;
unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_CHILD);
parent = unionfs_lock_parent(dentry, UNIONFS_DMUTEX_PARENT);
unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
valid = __unionfs_d_revalidate(dentry, parent, false, 0);
if (unlikely(!valid)) {
err = -ESTALE;
goto out;
}
/*
* It's only a bug if this dentry was not negative and couldn't be
* revalidated (shouldn't happen).
*/
BUG_ON(!valid && dentry->d_inode);
lower_dentry = find_writeable_branch(dir, dentry);
if (IS_ERR(lower_dentry)) {
err = PTR_ERR(lower_dentry);
goto out;
}
lower_parent_dentry = lock_parent(lower_dentry);
if (IS_ERR(lower_parent_dentry)) {
err = PTR_ERR(lower_parent_dentry);
goto out_unlock;
}
err = vfs_mknod(lower_parent_dentry->d_inode, lower_dentry, mode, dev);
if (!err) {
err = PTR_ERR(unionfs_interpose(dentry, dir->i_sb, 0));
if (!err) {
unionfs_copy_attr_times(dir);
fsstack_copy_inode_size(dir,
lower_parent_dentry->d_inode);
/* update no. of links on parent directory */
set_nlink(dir, unionfs_get_nlinks(dir));
}
}
out_unlock:
unlock_dir(lower_parent_dentry);
out:
dput(wh_dentry);
kfree(name);
if (!err) {
unionfs_postcopyup_setmnt(dentry);
unionfs_check_inode(dir);
unionfs_check_dentry(dentry);
}
unionfs_unlock_dentry(dentry);
unionfs_unlock_parent(dentry, parent);
unionfs_read_unlock(dentry->d_sb);
return err;
}
开发者ID:rhamilton1415,项目名称:steamlink-sdk,代码行数:67,代码来源:inode.c
注:本文中的set_nlink函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论