本文整理汇总了C++中dbend函数的典型用法代码示例。如果您正苦于以下问题:C++ dbend函数的具体用法?C++ dbend怎么用?C++ dbend使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbend函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: unionfs_reinterpose
/* like interpose above, but for an already existing dentry */
void unionfs_reinterpose(struct dentry *dentry)
{
struct dentry *lower_dentry;
struct inode *inode;
int bindex, bstart, bend;
verify_locked(dentry);
/* This is pre-allocated inode */
inode = dentry->d_inode;
bstart = dbstart(dentry);
bend = dbend(dentry);
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!lower_dentry)
continue;
if (!lower_dentry->d_inode)
continue;
if (unionfs_lower_inode_idx(inode, bindex))
continue;
unionfs_set_lower_inode_idx(inode, bindex,
igrab(lower_dentry->d_inode));
}
ibstart(inode) = dbstart(dentry);
ibend(inode) = dbend(dentry);
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:29,代码来源:main.c
示例2: __set_dentry
/* set lower dentry ptr and update bstart & bend if necessary */
static void __set_dentry(struct dentry *upper, struct dentry *lower,
int bindex)
{
unionfs_set_lower_dentry_idx(upper, bindex, lower);
if (likely(dbstart(upper) > bindex))
dbstart(upper) = bindex;
if (likely(dbend(upper) < bindex))
dbend(upper) = bindex;
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:10,代码来源:copyup.c
示例3: unionfs_ioctl_queryfile
/*
* return to user-space the branch indices containing the file in question
*
* We use fd_set and therefore we are limited to the number of the branches
* to FD_SETSIZE, which is currently 1024 - plenty for most people
*/
static int unionfs_ioctl_queryfile(struct file *file, struct dentry *parent,
unsigned int cmd, unsigned long arg)
{
int err = 0;
fd_set branchlist;
int bstart = 0, bend = 0, bindex = 0;
int orig_bstart, orig_bend;
struct dentry *dentry, *lower_dentry;
struct vfsmount *mnt;
dentry = file->f_path.dentry;
orig_bstart = dbstart(dentry);
orig_bend = dbend(dentry);
err = unionfs_partial_lookup(dentry, parent);
if (err)
goto out;
bstart = dbstart(dentry);
bend = dbend(dentry);
FD_ZERO(&branchlist);
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!lower_dentry)
continue;
if (likely(lower_dentry->d_inode))
FD_SET(bindex, &branchlist);
/* purge any lower objects after partial_lookup */
if (bindex < orig_bstart || bindex > orig_bend) {
dput(lower_dentry);
unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
iput(unionfs_lower_inode_idx(dentry->d_inode, bindex));
unionfs_set_lower_inode_idx(dentry->d_inode, bindex,
NULL);
mnt = unionfs_lower_mnt_idx(dentry, bindex);
if (!mnt)
continue;
unionfs_mntput(dentry, bindex);
unionfs_set_lower_mnt_idx(dentry, bindex, NULL);
}
}
/* restore original dentry's offsets */
dbstart(dentry) = orig_bstart;
dbend(dentry) = orig_bend;
ibstart(dentry->d_inode) = orig_bstart;
ibend(dentry->d_inode) = orig_bend;
err = copy_to_user((void __user *)arg, &branchlist, sizeof(fd_set));
if (unlikely(err))
err = -EFAULT;
out:
return err < 0 ? err : bend;
}
开发者ID:mayli,项目名称:unionfs-2.6.32.y,代码行数:60,代码来源:commonfops.c
示例4: unionfs_fill_inode
static void unionfs_fill_inode(struct dentry *dentry,
struct inode *inode)
{
struct inode *lower_inode;
struct dentry *lower_dentry;
int bindex, bstart, bend;
bstart = dbstart(dentry);
bend = dbend(dentry);
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!lower_dentry) {
unionfs_set_lower_inode_idx(inode, bindex, NULL);
continue;
}
/* Initialize the lower inode to the new lower inode. */
if (!lower_dentry->d_inode)
continue;
unionfs_set_lower_inode_idx(inode, bindex,
igrab(lower_dentry->d_inode));
}
ibstart(inode) = dbstart(dentry);
ibend(inode) = dbend(dentry);
/* Use attributes from the first branch. */
lower_inode = unionfs_lower_inode(inode);
/* Use different set of inode ops for symlinks & directories */
if (S_ISLNK(lower_inode->i_mode))
inode->i_op = &unionfs_symlink_iops;
else if (S_ISDIR(lower_inode->i_mode))
inode->i_op = &unionfs_dir_iops;
/* Use different set of file ops for directories */
if (S_ISDIR(lower_inode->i_mode))
inode->i_fop = &unionfs_dir_fops;
/* properly initialize special inodes */
if (S_ISBLK(lower_inode->i_mode) || S_ISCHR(lower_inode->i_mode) ||
S_ISFIFO(lower_inode->i_mode) || S_ISSOCK(lower_inode->i_mode))
init_special_inode(inode, lower_inode->i_mode,
lower_inode->i_rdev);
/* all well, copy inode attributes */
unionfs_copy_attr_all(inode, lower_inode);
fsstack_copy_inode_size(inode, lower_inode);
}
开发者ID:mrtos,项目名称:Logitech-Revue,代码行数:51,代码来源:main.c
示例5: unionfs_postcopyup_release
/*
* Post-copyup helper to release all non-directory source objects of a
* copied-up file. Regular files should have only one lower object.
*/
void unionfs_postcopyup_release(struct dentry *dentry)
{
int bstart, bend;
BUG_ON(S_ISDIR(dentry->d_inode->i_mode));
bstart = dbstart(dentry);
bend = dbend(dentry);
path_put_lowers(dentry, bstart + 1, bend, false);
iput_lowers(dentry->d_inode, bstart + 1, bend, false);
dbend(dentry) = bstart;
ibend(dentry->d_inode) = ibstart(dentry->d_inode) = bstart;
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:18,代码来源:copyup.c
示例6: __open_dir
/* unionfs_open helper function: open a directory */
static int __open_dir(struct inode *inode, struct file *file)
{
struct dentry *lower_dentry;
struct file *lower_file;
int bindex, bstart, bend;
struct vfsmount *mnt;
bstart = fbstart(file) = dbstart(file->f_path.dentry);
bend = fbend(file) = dbend(file->f_path.dentry);
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry =
unionfs_lower_dentry_idx(file->f_path.dentry, bindex);
if (!lower_dentry)
continue;
dget(lower_dentry);
unionfs_mntget(file->f_path.dentry, bindex);
mnt = unionfs_lower_mnt_idx(file->f_path.dentry, bindex);
lower_file = dentry_open(lower_dentry, mnt, file->f_flags,
current_cred());
if (IS_ERR(lower_file))
return PTR_ERR(lower_file);
unionfs_set_lower_file_idx(file, bindex, lower_file);
/*
* The branchget goes after the open, because otherwise
* we would miss the reference on release.
*/
branchget(inode->i_sb, bindex);
}
return 0;
}
开发者ID:mayli,项目名称:unionfs-2.6.32.y,代码行数:36,代码来源:commonfops.c
示例7: open_all_files
/* open all lower files for a given file */
static int open_all_files(struct file *file)
{
int bindex, bstart, bend, err = 0;
struct file *lower_file;
struct dentry *lower_dentry;
struct dentry *dentry = file->f_path.dentry;
struct super_block *sb = dentry->d_sb;
bstart = dbstart(dentry);
bend = dbend(dentry);
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!lower_dentry)
continue;
dget(lower_dentry);
unionfs_mntget(dentry, bindex);
branchget(sb, bindex);
lower_file =
dentry_open(lower_dentry,
unionfs_lower_mnt_idx(dentry, bindex),
file->f_flags, current_cred());
if (IS_ERR(lower_file)) {
branchput(sb, bindex);
err = PTR_ERR(lower_file);
goto out;
} else {
unionfs_set_lower_file_idx(file, bindex, lower_file);
}
}
out:
return err;
}
开发者ID:mayli,项目名称:unionfs-2.6.32.y,代码行数:36,代码来源:commonfops.c
示例8: __clear
/*
* dput the lower references for old and new dentry & clear a lower dentry
* pointer
*/
static void __clear(struct dentry *dentry, struct dentry *old_lower_dentry,
int old_bstart, int old_bend,
struct dentry *new_lower_dentry, int new_bindex)
{
/* get rid of the lower dentry and all its traces */
unionfs_set_lower_dentry_idx(dentry, new_bindex, NULL);
dbstart(dentry) = old_bstart;
dbend(dentry) = old_bend;
dput(new_lower_dentry);
dput(old_lower_dentry);
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:16,代码来源:copyup.c
示例9: do_delayed_copyup
/* perform a delayed copyup of a read-write file on a read-only branch */
static int do_delayed_copyup(struct file *file, struct dentry *parent)
{
int bindex, bstart, bend, err = 0;
struct dentry *dentry = file->f_path.dentry;
struct inode *parent_inode = parent->d_inode;
bstart = fbstart(file);
bend = fbend(file);
BUG_ON(!S_ISREG(dentry->d_inode->i_mode));
unionfs_check_file(file);
for (bindex = bstart - 1; bindex >= 0; bindex--) {
if (!d_deleted(dentry))
err = copyup_file(parent_inode, file, bstart,
bindex,
i_size_read(dentry->d_inode));
else
err = copyup_deleted_file(file, dentry, parent,
bstart, bindex);
/* if succeeded, set lower open-file flags and break */
if (!err) {
struct file *lower_file;
lower_file = unionfs_lower_file_idx(file, bindex);
lower_file->f_flags = file->f_flags;
break;
}
}
if (err || (bstart <= fbstart(file)))
goto out;
bend = fbend(file);
for (bindex = bstart; bindex <= bend; bindex++) {
if (unionfs_lower_file_idx(file, bindex)) {
branchput(dentry->d_sb, bindex);
fput(unionfs_lower_file_idx(file, bindex));
unionfs_set_lower_file_idx(file, bindex, NULL);
}
}
path_put_lowers(dentry, bstart, bend, false);
iput_lowers(dentry->d_inode, bstart, bend, false);
/* for reg file, we only open it "once" */
fbend(file) = fbstart(file);
dbend(dentry) = dbstart(dentry);
ibend(dentry->d_inode) = ibstart(dentry->d_inode);
out:
unionfs_check_file(file);
return err;
}
开发者ID:mayli,项目名称:unionfs-2.6.32.y,代码行数:50,代码来源:commonfops.c
示例10: __cleanup_dentry
/* purge a dentry's lower-branch states (dput/mntput, etc.) */
static void __cleanup_dentry(struct dentry *dentry, int bindex,
int old_bstart, int old_bend)
{
int loop_start;
int loop_end;
int new_bstart = -1;
int new_bend = -1;
int i;
loop_start = min(old_bstart, bindex);
loop_end = max(old_bend, bindex);
/*
* This loop sets the bstart and bend for the new dentry by
* traversing from left to right. It also dputs all negative
* dentries except bindex
*/
for (i = loop_start; i <= loop_end; i++) {
if (!unionfs_lower_dentry_idx(dentry, i))
continue;
if (i == bindex) {
new_bend = i;
if (new_bstart < 0)
new_bstart = i;
continue;
}
if (!unionfs_lower_dentry_idx(dentry, i)->d_inode) {
dput(unionfs_lower_dentry_idx(dentry, i));
unionfs_set_lower_dentry_idx(dentry, i, NULL);
unionfs_mntput(dentry, i);
unionfs_set_lower_mnt_idx(dentry, i, NULL);
} else {
if (new_bstart < 0)
new_bstart = i;
new_bend = i;
}
}
if (new_bstart < 0)
new_bstart = bindex;
if (new_bend < 0)
new_bend = bindex;
dbstart(dentry) = new_bstart;
dbend(dentry) = new_bend;
}
开发者ID:kizukukoto,项目名称:WDN900_GPL,代码行数:50,代码来源:copyup.c
示例11: open_highest_file
/* open the highest priority file for a given upper file */
static int open_highest_file(struct file *file, bool willwrite)
{
int bindex, bstart, bend, err = 0;
struct file *lower_file;
struct dentry *lower_dentry;
struct dentry *dentry = file->f_path.dentry;
struct dentry *parent = dget_parent(dentry);
struct inode *parent_inode = parent->d_inode;
struct super_block *sb = dentry->d_sb;
bstart = dbstart(dentry);
bend = dbend(dentry);
lower_dentry = unionfs_lower_dentry(dentry);
if (willwrite && IS_WRITE_FLAG(file->f_flags) && is_robranch(dentry)) {
for (bindex = bstart - 1; bindex >= 0; bindex--) {
err = copyup_file(parent_inode, file, bstart, bindex,
i_size_read(dentry->d_inode));
if (!err)
break;
}
atomic_set(&UNIONFS_F(file)->generation,
atomic_read(&UNIONFS_I(dentry->d_inode)->
generation));
goto out;
}
dget(lower_dentry);
unionfs_mntget(dentry, bstart);
lower_file = dentry_open(lower_dentry,
unionfs_lower_mnt_idx(dentry, bstart),
file->f_flags, current_cred());
if (IS_ERR(lower_file)) {
err = PTR_ERR(lower_file);
goto out;
}
branchget(sb, bstart);
unionfs_set_lower_file(file, lower_file);
/* Fix up the position. */
lower_file->f_pos = file->f_pos;
memcpy(&lower_file->f_ra, &file->f_ra, sizeof(struct file_ra_state));
out:
dput(parent);
return err;
}
开发者ID:mayli,项目名称:unionfs-2.6.32.y,代码行数:47,代码来源:commonfops.c
示例12: update_bstart
/*
* scan through the lower dentry objects, and set bstart to reflect the
* starting branch
*/
void update_bstart(struct dentry *dentry)
{
int bindex;
int bstart = dbstart(dentry);
int bend = dbend(dentry);
struct dentry *lower_dentry;
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!lower_dentry)
continue;
if (lower_dentry->d_inode) {
dbstart(dentry) = bindex;
break;
}
dput(lower_dentry);
unionfs_set_lower_dentry_idx(dentry, bindex, NULL);
}
}
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:23,代码来源:lookup.c
示例13: unionfs_ioctl_queryfile
int unionfs_ioctl_queryfile(struct file *file, unsigned int cmd,
unsigned long arg)
{
int err = 0;
fd_set branchlist;
int bstart = 0, bend = 0, bindex = 0;
struct dentry *dentry, *hidden_dentry;
print_entry_location();
dentry = file->f_dentry;
lock_dentry(dentry);
if ((err = unionfs_partial_lookup(dentry)))
goto out;
bstart = dbstart(dentry);
bend = dbend(dentry);
FD_ZERO(&branchlist);
for (bindex = bstart; bindex <= bend; bindex++) {
hidden_dentry = dtohd_index(dentry, bindex);
if (!hidden_dentry)
continue;
if (hidden_dentry->d_inode)
FD_SET(bindex, &branchlist);
}
err = copy_to_user((void *)arg, &branchlist, sizeof(fd_set));
if (err) {
err = -EFAULT;
goto out;
}
out:
unlock_dentry(dentry);
err = err < 0 ? err : bend;
print_exit_status(err);
return (err);
}
开发者ID:BackupTheBerlios,项目名称:dss-svn,代码行数:40,代码来源:branchman.c
示例14: unionfs_setattr
static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
{
int err = 0;
struct dentry *lower_dentry;
struct dentry *parent;
struct inode *inode;
struct inode *lower_inode;
int bstart, bend, bindex;
loff_t size;
struct iattr lower_ia;
/* check if user has permission to change inode */
err = inode_change_ok(dentry->d_inode, ia);
if (err)
goto out_err;
unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_CHILD);
parent = unionfs_lock_parent(dentry, UNIONFS_DMUTEX_PARENT);
unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
if (unlikely(!__unionfs_d_revalidate(dentry, parent, false, 0))) {
err = -ESTALE;
goto out;
}
bstart = dbstart(dentry);
bend = dbend(dentry);
inode = dentry->d_inode;
/*
* mode change is for clearing setuid/setgid. Allow lower filesystem
* to reinterpret it in its own way.
*/
if (ia->ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
ia->ia_valid &= ~ATTR_MODE;
lower_dentry = unionfs_lower_dentry(dentry);
if (!lower_dentry) { /* should never happen after above revalidate */
err = -EINVAL;
goto out;
}
/*
* Get the lower inode directly from lower dentry, in case ibstart
* is -1 (which happens when the file is open but unlinked.
*/
lower_inode = lower_dentry->d_inode;
/* check if user has permission to change lower inode */
err = inode_change_ok(lower_inode, ia);
if (err)
goto out;
/* copyup if the file is on a read only branch */
if (is_robranch_super(dentry->d_sb, bstart)
|| __is_rdonly(lower_inode)) {
/* check if we have a branch to copy up to */
if (bstart <= 0) {
err = -EACCES;
goto out;
}
if (ia->ia_valid & ATTR_SIZE)
size = ia->ia_size;
else
size = i_size_read(inode);
/* copyup to next available branch */
for (bindex = bstart - 1; bindex >= 0; bindex--) {
err = copyup_dentry(parent->d_inode,
dentry, bstart, bindex,
dentry->d_name.name,
dentry->d_name.len,
NULL, size);
if (!err)
break;
}
if (err)
goto out;
/* get updated lower_dentry/inode after copyup */
lower_dentry = unionfs_lower_dentry(dentry);
lower_inode = unionfs_lower_inode(inode);
/*
* check for whiteouts in writeable branch, and remove them
* if necessary.
*/
if (lower_dentry) {
err = check_unlink_whiteout(dentry, lower_dentry,
bindex);
if (err > 0) /* ignore if whiteout found and removed */
err = 0;
}
}
/*
* If shrinking, first truncate upper level to cancel writing dirty
* pages beyond the new eof; and also if its' maxbytes is more
* limiting (fail with -EFBIG before making any change to the lower
* level). There is no need to vmtruncate the upper level
* afterwards in the other cases: we fsstack_copy_inode_size from
* the lower level.
//.........这里部分代码省略.........
开发者ID:rhamilton1415,项目名称:steamlink-sdk,代码行数:101,代码来源:inode.c
示例15: unionfs_mkdir
static int unionfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
{
int err = 0;
struct dentry *lower_dentry = NULL;
struct dentry *lower_parent_dentry = NULL;
struct dentry *parent;
int bindex = 0, bstart;
char *name = NULL;
int valid;
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; /* same as what real_lookup does */
goto out;
}
bstart = dbstart(dentry);
lower_dentry = unionfs_lower_dentry(dentry);
/* check for a whiteout in new dentry branch, and delete it */
err = check_unlink_whiteout(dentry, lower_dentry, bstart);
if (err > 0) /* whiteout found and removed successfully */
err = 0;
if (err) {
/* exit if the error returned was NOT -EROFS */
if (!IS_COPYUP_ERR(err))
goto out;
bstart--;
}
/* check if copyup's needed, and mkdir */
for (bindex = bstart; bindex >= 0; bindex--) {
int i;
int bend = dbend(dentry);
if (is_robranch_super(dentry->d_sb, bindex))
continue;
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (!lower_dentry) {
lower_dentry = create_parents(dir, dentry,
dentry->d_name.name,
bindex);
if (!lower_dentry || IS_ERR(lower_dentry)) {
printk(KERN_ERR "unionfs: lower dentry "
" NULL for bindex = %d\n", bindex);
continue;
}
}
lower_parent_dentry = lock_parent(lower_dentry);
if (IS_ERR(lower_parent_dentry)) {
err = PTR_ERR(lower_parent_dentry);
goto out;
}
err = vfs_mkdir(lower_parent_dentry->d_inode, lower_dentry,
mode);
unlock_dir(lower_parent_dentry);
/* did the mkdir succeed? */
if (err)
break;
for (i = bindex + 1; i <= bend; i++) {
/* XXX: use path_put_lowers? */
if (unionfs_lower_dentry_idx(dentry, i)) {
dput(unionfs_lower_dentry_idx(dentry, i));
unionfs_set_lower_dentry_idx(dentry, i, NULL);
}
}
dbend(dentry) = bindex;
/*
* Only INTERPOSE_LOOKUP can return a value other than 0 on
* 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 number of links on parent directory */
set_nlink(dir, unionfs_get_nlinks(dir));
}
err = make_dir_opaque(dentry, dbstart(dentry));
if (err) {
printk(KERN_ERR "unionfs: mkdir: error creating "
".wh.__dir_opaque: %d\n", err);
goto out;
}
//.........这里部分代码省略.........
开发者ID:rhamilton1415,项目名称:steamlink-sdk,代码行数:101,代码来源:inode.c
示例16: print_entry_location
/* This function replicates the directory structure upto given dentry
* in the bindex branch. */
struct dentry *create_parents_named(struct inode *dir, struct dentry *dentry,
const char *name, int bindex)
{
int err;
struct dentry *child_dentry;
struct dentry *parent_dentry;
struct dentry *hidden_parent_dentry = NULL;
struct dentry *hidden_dentry = NULL;
const char *childname;
unsigned int childnamelen;
int old_kmalloc_size;
int kmalloc_size;
int num_dentry;
int count;
int old_bstart;
int old_bend;
struct dentry **path = NULL;
struct dentry **tmp_path;
print_entry_location();
verify_locked(dentry);
/* There is no sense allocating any less than the minimum. */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
kmalloc_size = malloc_sizes[0].cs_size;
#else
kmalloc_size = 32;
#endif
num_dentry = kmalloc_size / sizeof(struct dentry *);
if ((err = is_robranch_super(dir->i_sb, bindex))) {
hidden_dentry = ERR_PTR(err);
goto out;
}
fist_print_dentry("IN: create_parents_named", dentry);
fist_dprint(8, "name = %s\n", name);
old_bstart = dbstart(dentry);
old_bend = dbend(dentry);
path = (struct dentry **)KMALLOC(kmalloc_size, GFP_KERNEL);
memset(path, 0, kmalloc_size);
/* assume the negative dentry of unionfs as the parent dentry */
parent_dentry = dentry;
count = 0;
/* This loop finds the first parent that exists in the given branch.
* We start building the directory structure from there. At the end
* of the loop, the following should hold:
* child_dentry is the first nonexistent child
* parent_dentry is the first existent parent
* path[0] is the = deepest child
* path[count] is the first child to create
*/
do {
child_dentry = parent_dentry;
/* find the parent directory dentry in unionfs */
parent_dentry = child_dentry->d_parent;
lock_dentry(parent_dentry);
/* find out the hidden_parent_dentry in the given branch */
hidden_parent_dentry = dtohd_index(parent_dentry, bindex);
/* store the child dentry */
path[count++] = child_dentry;
if (count == num_dentry) {
old_kmalloc_size = kmalloc_size;
kmalloc_size *= 2;
num_dentry = kmalloc_size / sizeof(struct dentry *);
tmp_path =
(struct dentry **)KMALLOC(kmalloc_size, GFP_KERNEL);
if (!tmp_path) {
hidden_dentry = ERR_PTR(-ENOMEM);
goto out;
}
memset(tmp_path, 0, kmalloc_size);
memcpy(tmp_path, path, old_kmalloc_size);
KFREE(path);
path = tmp_path;
tmp_path = NULL;
}
} while (!hidden_parent_dentry);
count--;
/* This is basically while(child_dentry != dentry). This loop is
* horrible to follow and should be replaced with cleaner code. */
while (1) {
PASSERT(child_dentry);
PASSERT(parent_dentry);
PASSERT(parent_dentry->d_inode);
//.........这里部分代码省略.........
开发者ID:rickgaiser,项目名称:kernelloader,代码行数:101,代码来源:copyup.c
示例17: copyup_named_dentry
int copyup_named_dentry(struct inode *dir, struct dentry *dentry,
int bstart, int new_bindex, char *name,
int namelen, struct file **copyup_file, int len)
{
struct dentry *new_hidden_dentry;
struct dentry *old_hidden_dentry = NULL;
struct super_block *sb;
struct file *input_file = NULL;
struct file *output_file = NULL;
ssize_t read_bytes, write_bytes;
mm_segment_t old_fs;
int err = 0;
char *buf;
int old_bindex;
int got_branch_input = -1;
int got_branch_output = -1;
int old_bstart;
int old_bend;
int size = len;
struct dentry *new_hidden_parent_dentry;
mm_segment_t oldfs;
char *symbuf = NULL;
uid_t saved_uid = current->fsuid;
gid_t saved_gid = current->fsgid;
print_entry_location();
verify_locked(dentry);
fist_print_dentry("IN: copyup_named_dentry", dentry);
old_bindex = bstart;
old_bstart = dbstart(dentry);
old_bend = dbend(dentry);
ASSERT(new_bindex >= 0);
ASSERT(new_bindex < old_bindex);
PASSERT(dir);
PASSERT(dentry);
sb = dir->i_sb;
if ((err = is_robranch_super(sb, new_bindex)))
goto out;
/* Create the directory structure above this dentry. */
new_hidden_dentry = create_parents_named(dir, dentry, name, new_bindex);
PASSERT(new_hidden_dentry);
if (IS_ERR(new_hidden_dentry)) {
err = PTR_ERR(new_hidden_dentry);
goto out;
}
fist_print_generic_dentry("Copyup Object", new_hidden_dentry);
/* Now we actually create the object. */
old_hidden_dentry = dtohd_index(dentry, old_bindex);
PASSERT(old_hidden_dentry);
PASSERT(old_hidden_dentry->d_inode);
DGET(old_hidden_dentry);
/* For symlinks, we must read the link before we lock the directory. */
if (S_ISLNK(old_hidden_dentry->d_inode->i_mode)) {
PASSERT(old_hidden_dentry->d_inode->i_op);
PASSERT(old_hidden_dentry->d_inode->i_op->readlink);
symbuf = KMALLOC(PATH_MAX, GFP_UNIONFS);
if (!symbuf) {
err = -ENOMEM;
goto copyup_readlink_err;
}
oldfs = get_fs();
set_fs(KERNEL_DS);
err =
old_hidden_dentry->d_inode->i_op->
readlink(old_hidden_dentry, symbuf, PATH_MAX);
set_fs(oldfs);
if (err < 0)
goto copyup_readlink_err;
symbuf[err] = '\0';
}
/* Now we lock the parent, and create the object in the new branch. */
new_hidden_parent_dentry = lock_parent(new_hidden_dentry);
current->fsuid = new_hidden_parent_dentry->d_inode->i_uid;
current->fsgid = new_hidden_parent_dentry->d_inode->i_gid;
if (S_ISDIR(old_hidden_dentry->d_inode->i_mode)) {
err = vfs_mkdir(new_hidden_parent_dentry->d_inode,
new_hidden_dentry, S_IRWXU);
} else if (S_ISLNK(old_hidden_dentry->d_inode->i_mode)) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
err = vfs_symlink(new_hidden_parent_dentry->d_inode,
new_hidden_dentry, symbuf);
#else
err = vfs_symlink(new_hidden_parent_dentry->d_inode,
new_hidden_dentry, symbuf, S_IRWXU);
#endif
} else if (S_ISBLK(old_hidden_dentry->d_inode->i_mode)
|| S_ISCHR(old_hidden_dentry->d_inode->i_mode)
|| S_ISFIFO(old_hidden_dentry->d_inode->i_mode)
|| S_ISSOCK(old_hidden_dentry->d_inode->i_mode)) {
//.........这里部分代码省略.........
开发者ID:rickgaiser,项目名称:kernelloader,代码行数:101,代码来源:copyup.c
示例18: verify_locked
/*
* Main (and complex) driver function for Unionfs's lookup
*
* Returns: NULL (ok), ERR_PTR if an error occurred, or a non-null non-error
* PTR if d_splice returned a different dentry.
*
* If lookupmode is INTERPOSE_PARTIAL/REVAL/REVAL_NEG, the passed dentry's
* inode info must be locked. If lookupmode is INTERPOSE_LOOKUP (i.e., a
* newly looked-up dentry), then unionfs_lookup_backend will return a locked
* dentry's info, which the caller must unlock.
*/
struct dentry *unionfs_lookup_full(struct dentry *dentry,
struct dentry *parent, int lookupmode)
{
int err = 0;
struct dentry *lower_dentry = NULL;
struct vfsmount *lower_mnt;
struct vfsmount *lower_dir_mnt;
struct dentry *wh_lower_dentry = NULL;
struct dentry *lower_dir_dentry = NULL;
struct dentry *d_interposed = NULL;
int bindex, bstart, bend, bopaque;
int opaque, num_positive = 0;
const char *name;
int namelen;
int pos_start, pos_end;
/*
* We should already have a lock on this dentry in the case of a
* partial lookup, or a revalidation. Otherwise it is returned from
* new_dentry_private_data already locked.
*/
verify_locked(dentry);
verify_locked(parent);
/* must initialize dentry operations */
dentry->d_op = &unionfs_dops;
/* We never partial lookup the root directory. */
if (IS_ROOT(dentry))
goto out;
name = dentry->d_name.name;
namelen = dentry->d_name.len;
/* No dentries should get created for possible whiteout names. */
if (!is_validname(name)) {
err = -EPERM;
goto out_free;
}
/* Now start the actual lookup procedure. */
bstart = dbstart(parent);
bend = dbend(parent);
bopaque = dbopaque(parent);
BUG_ON(bstart < 0);
/* adjust bend to bopaque if needed */
if ((bopaque >= 0) && (bopaque < bend))
bend = bopaque;
/* lookup all possible dentries */
for (bindex = bstart; bindex <= bend; bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
lower_mnt = unionfs_lower_mnt_idx(dentry, bindex);
/* skip if we already have a positive lower dentry */
if (lower_dentry) {
if (dbstart(dentry) < 0)
dbstart(dentry) = bindex;
if (bindex > dbend(dentry))
dbend(dentry) = bindex;
if (lower_dentry->d_inode)
num_positive++;
continue;
}
lower_dir_dentry =
unionfs_lower_dentry_idx(parent, bindex);
/* if the lower dentry's parent does not exist, skip this */
if (!lower_dir_dentry || !lower_dir_dentry->d_inode)
continue;
/* also skip it if the parent isn't a directory. */
if (!S_ISDIR(lower_dir_dentry->d_inode->i_mode))
continue; /* XXX: should be BUG_ON */
/* check for whiteouts: stop lookup if found */
wh_lower_dentry = lookup_whiteout(name, lower_dir_dentry);
if (IS_ERR(wh_lower_dentry)) {
err = PTR_ERR(wh_lower_dentry);
goto out_free;
}
if (wh_lower_dentry->d_inode) {
dbend(dentry) = dbopaque(dentry) = bindex;
if (dbstart(dentry) < 0)
dbstart(dentry) = bindex;
dput(wh_lower_dentry);
break;
//.........这里部分代码省略.........
开发者ID:Mr-Aloof,项目名称:wl500g,代码行数:101,代码来源:lookup.c
示例19: __unionfs_check_file
void __unionfs_check_file(const struct file *file,
const char *fname, const char *fxn, int line)
{
int bindex;
int dstart, dend, fstart, fend;
struct dentry *dentry;
struct file *lower_file;
struct inode *inode;
struct super_block *sb;
int printed_caller = 0;
BUG_ON(!file);
dentry = file->f_path.dentry;
sb = dentry->d_sb;
dstart = dbstart(dentry);
dend = dbend(dentry);
BUG_ON(dstart > dend);
fstart = fbstart(file);
fend = fbend(file);
BUG_ON(fstart > fend);
if (unlikely((fstart == -1 && fend != -1) ||
(fstart != -1 && fend == -1))) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CF0: file/dentry=%p:%p fstart/end=%d:%d\n",
file, dentry, fstart, fend);
}
if (unlikely(fstart != dstart)) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CF1: file/dentry=%p:%p fstart=%d dstart=%d\n",
file, dentry, fstart, dstart);
}
if (unlikely(fend != dend)) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CF2: file/dentry=%p:%p fend=%d dend=%d\n",
file, dentry, fend, dend);
}
inode = dentry->d_inode;
if (!S_ISDIR(inode->i_mode)) {
if (unlikely(fend != fstart)) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CF3: file/inode=%p:%p fstart=%d fend=%d\n",
file, inode, fstart, fend);
}
if (unlikely(dend != dstart)) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CF4: file/dentry=%p:%p dstart=%d dend=%d\n",
file, dentry, dstart, dend);
}
}
/*
* check for NULL dentries inside the start/end range, or
* non-NULL dentries outside the start/end range.
*/
for (bindex = sbstart(sb); bindex < sbmax(sb); bindex++) {
lower_file = unionfs_lower_file_idx(file, bindex);
if (lower_file) {
if (unlikely(bindex < fstart || bindex > fend)) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CF5: file/lower=%p:%p bindex=%d "
"fstart/end=%d:%d\n", file,
lower_file, bindex, fstart, fend);
}
} else { /* lower_file == NULL */
if (bindex >= fstart && bindex <= fend) {
/*
* directories can have NULL lower inodes in
* b/t start/end, but NOT if at the
* start/end range.
*/
if (unlikely(!(S_ISDIR(inode->i_mode) &&
bindex > fstart &&
bindex < fend))) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CF6: file/lower=%p:%p "
"bindex=%d fstart/end=%d:%d\n",
file, lower_file, bindex,
fstart, fend);
}
}
}
}
__unionfs_check_dentry(dentry, fname, fxn, line);
}
开发者ID:robacklin,项目名称:ts7800,代码行数:86,代码来源:debug.c
示例20: __unionfs_check_dentry
void __unionfs_check_dentry(const struct dentry *dentry,
const char *fname, const char *fxn, int line)
{
int bindex;
int dstart, dend, istart, iend;
struct dentry *lower_dentry;
struct inode *inode, *lower_inode;
struct super_block *sb;
struct vfsmount *lower_mnt;
int printed_caller = 0;
void *poison_ptr;
BUG_ON(!dentry);
sb = dentry->d_sb;
inode = dentry->d_inode;
dstart = dbstart(dentry);
dend = dbend(dentry);
/* don't check dentry/mnt if no lower branches */
if (dstart < 0 && dend < 0)
goto check_inode;
BUG_ON(dstart > dend);
if (unlikely((dstart == -1 && dend != -1) ||
(dstart != -1 && dend == -1))) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CD0: dentry=%p dstart/end=%d:%d\n",
dentry, dstart, dend);
}
/*
* check for NULL dentries inside the start/end range, or
* non-NULL dentries outside the start/end range.
*/
for (bindex = sbstart(sb); bindex < sbmax(sb); bindex++) {
lower_dentry = unionfs_lower_dentry_idx(dentry, bindex);
if (lower_dentry) {
if (unlikely(bindex < dstart || bindex > dend)) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CD1: dentry/lower=%p:%p(%p) "
"bindex=%d dstart/end=%d:%d\n",
dentry, lower_dentry,
(lower_dentry ? lower_dentry->d_inode :
(void *) -1L),
bindex, dstart, dend);
}
} else { /* lower_dentry == NULL */
if (bindex < dstart || bindex > dend)
continue;
/*
* Directories can have NULL lower inodes in b/t
* start/end, but NOT if at the start/end range.
* Ignore this rule, however, if this is a NULL
* dentry or a deleted dentry.
*/
if (unlikely(!d_deleted((struct dentry *) dentry) &&
inode &&
!(inode && S_ISDIR(inode->i_mode) &&
bindex > dstart && bindex < dend))) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CD2: dentry/lower=%p:%p(%p) "
"bindex=%d dstart/end=%d:%d\n",
dentry, lower_dentry,
(lower_dentry ?
lower_dentry->d_inode :
(void *) -1L),
bindex, dstart, dend);
}
}
}
/* check for vfsmounts same as for dentries */
for (bindex = sbstart(sb); bindex < sbmax(sb); bindex++) {
lower_mnt = unionfs_lower_mnt_idx(dentry, bindex);
if (lower_mnt) {
if (unlikely(bindex < dstart || bindex > dend)) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CM0: dentry/lmnt=%p:%p bindex=%d "
"dstart/end=%d:%d\n", dentry,
lower_mnt, bindex, dstart, dend);
}
} else { /* lower_mnt == NULL */
if (bindex < dstart || bindex > dend)
continue;
/*
* Directories can have NULL lower inodes in b/t
* start/end, but NOT if at the start/end range.
* Ignore this rule, however, if this is a NULL
* dentry.
*/
if (unlikely(inode &&
!(inode && S_ISDIR(inode->i_mode) &&
bindex > dstart && bindex < dend))) {
PRINT_CALLER(fname, fxn, line);
pr_debug(" CM1: dentry/lmnt=%p:%p "
"bindex=%d dstart/end=%d:%d\n",
dentry, lower_mnt, bindex,
dstart, dend);
}
}
}
//.........这里部分代码省略.........
开发者ID:robacklin,项目名称:ts7800,代码行数:101,代码来源:debug.c
注:本文中的dbend函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论