• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dentry_open函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dentry_open函数的典型用法代码示例。如果您正苦于以下问题:C++ dentry_open函数的具体用法?C++ dentry_open怎么用?C++ dentry_open使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dentry_open函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: afs_linux_raw_open

struct file *
afs_linux_raw_open(afs_dcache_id_t *ainode)
{
    struct inode *tip = NULL;
    struct dentry *dp = NULL;
    struct file* filp;

    dp = afs_get_dentry_from_fh(afs_cacheSBp, ainode, cache_fh_len, cache_fh_type,
		afs_fh_acceptable);
    if ((!dp) || IS_ERR(dp))
           osi_Panic("Can't get dentry\n");
    tip = dp->d_inode;
    tip->i_flags |= S_NOATIME;	/* Disable updating access times. */

#if defined(STRUCT_TASK_STRUCT_HAS_CRED)
    /* Use stashed credentials - prevent selinux/apparmor problems  */
    filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, cache_creds);
    if (IS_ERR(filp))
	filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred());
#else
    filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR);
#endif
    if (IS_ERR(filp))
	osi_Panic("Can't open file: %d\n", (int) PTR_ERR(filp));
    return filp;
}
开发者ID:SimonWilkinson,项目名称:openafs,代码行数:26,代码来源:osi_file.c


示例2: do_kern_mount

static struct file *do_open(char *name, int flags)
{
	struct nameidata nd;
	int error;

	nd.mnt = do_kern_mount("nfsd", 0, "nfsd", NULL);

	if (IS_ERR(nd.mnt))
		return (struct file *)nd.mnt;

	nd.dentry = dget(nd.mnt->mnt_root);
	nd.last_type = LAST_ROOT;
	nd.flags = 0;
	nd.depth = 0;

	error = path_walk(name, &nd);
	if (error)
		return ERR_PTR(error);

	if (flags == O_RDWR)
		error = may_open(&nd,MAY_READ|MAY_WRITE,FMODE_READ|FMODE_WRITE);
	else
		error = may_open(&nd, MAY_WRITE, FMODE_WRITE);

	if (!error)
		return dentry_open(nd.dentry, nd.mnt, flags);

	path_release(&nd);
	return ERR_PTR(error);
}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:30,代码来源:nfsctl.c


示例3: __open_dir

static int __open_dir(struct inode *inode, struct file *file,
			struct dentry *parent)
{
	struct dentry *lower_dentry;
	struct file *lower_file;
	struct vfsmount *lower_mnt;
	struct dentry *dentry = file->f_path.dentry;
	int i = 0, idx = 0;
	for (i = 0; i <= 1; i++) {
		lower_dentry = wrapfs_lower_dentry_idx(dentry, i);
		if (!lower_dentry || !lower_dentry->d_inode)
			continue;
		dget(lower_dentry);
		lower_mnt = mntget(wrapfs_lower_mnt_idx(dentry, i));
		if (!lower_mnt)
			lower_mnt = mntget(wrapfs_lower_mnt_idx(parent, i));

		lower_file = dentry_open(lower_dentry,
					lower_mnt, file->f_flags,
					current_cred());
		if (IS_ERR(lower_file))
			return PTR_ERR(lower_file);

		wrapfs_set_lower_file_idx(file, i, lower_file);
		if (!wrapfs_lower_mnt_idx(dentry, i))
			wrapfs_set_lower_mnt_idx(dentry, i, lower_mnt);

		branchget(inode->i_sb, i);
		idx = i;
	}

	fsstack_copy_attr_all(inode, wrapfs_lower_inode_idx(inode, idx));
	return 0;
}
开发者ID:raghavendrasuvvari,项目名称:U2fs-FileSystem,代码行数:34,代码来源:file.c


示例4: autofs_dev_ioctl_open_mountpoint

/*
 * Open a file descriptor on the autofs mount point corresponding
 * to the given path and device number (aka. new_encode_dev(sb->s_dev)).
 */
static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
{
	int err, fd;

	fd = get_unused_fd_flags(O_CLOEXEC);
	if (likely(fd >= 0)) {
		struct file *filp;
		struct path path;

		err = find_autofs_mount(name, &path, test_by_dev, &devid);
		if (err)
			goto out;

		filp = dentry_open(&path, O_RDONLY, current_cred());
		path_put(&path);
		if (IS_ERR(filp)) {
			err = PTR_ERR(filp);
			goto out;
		}

		fd_install(fd, filp);
	}

	return fd;

out:
	put_unused_fd(fd);
	return err;
}
开发者ID:avagin,项目名称:linux,代码行数:33,代码来源:dev-ioctl.c


示例5: 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


示例6: afs_linux_raw_open

struct file *
afs_linux_raw_open(afs_dcache_id_t *ainode)
{
    struct inode *tip = NULL;
    struct dentry *dp = NULL;
    struct file* filp;

    dp = afs_get_dentry_from_fh(afs_cacheSBp, ainode, cache_fh_len, cache_fh_type,
		afs_fh_acceptable);
    if ((!dp) || IS_ERR(dp))
           osi_Panic("Can't get dentry\n");
    tip = dp->d_inode;
    tip->i_flags |= S_NOATIME;	/* Disable updating access times. */

#if defined(STRUCT_TASK_STRUCT_HAS_CRED)
    /* Use stashed credentials - prevent selinux/apparmor problems  */
    filp = afs_dentry_open(dp, afs_cacheMnt, O_RDWR, cache_creds);
    if (IS_ERR(filp))
	filp = afs_dentry_open(dp, afs_cacheMnt, O_RDWR, current_cred());
#else
    filp = dentry_open(dget(dp), mntget(afs_cacheMnt), O_RDWR);
#endif
    if (IS_ERR(filp)) {
	afs_warn("afs: Cannot open cache file (code %d). Trying to continue, "
                 "but AFS accesses may return errors or panic the system\n",
                 (int) PTR_ERR(filp));
        filp = NULL;
    }

    dput(dp);

    return filp;
}
开发者ID:openafs,项目名称:openafs,代码行数:33,代码来源:osi_file.c


示例7: do_kern_mount

static struct file *do_open(char *name, int flags)
{
	struct nameidata nd;
	struct vfsmount *mnt;
	int error;

	mnt = do_kern_mount("nfsd", 0, "nfsd", NULL);
	if (IS_ERR(mnt))
		return (struct file *)mnt;

	error = vfs_path_lookup(mnt->mnt_root, mnt, name, 0, &nd);
	mntput(mnt);	/* drop do_kern_mount reference */
	if (error)
		return ERR_PTR(error);

	if (flags == O_RDWR)
		error = may_open(&nd,MAY_READ|MAY_WRITE,FMODE_READ|FMODE_WRITE);
	else
		error = may_open(&nd, MAY_WRITE, FMODE_WRITE);

	if (!error)
		return dentry_open(nd.path.dentry, nd.path.mnt, flags);

	path_put(&nd.path);
	return ERR_PTR(error);
}
开发者ID:deepikateriar,项目名称:Onlive-Source-Backup,代码行数:26,代码来源:nfsctl.c


示例8: __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


示例9: nfsio_prepare_snapshot

static int nfsio_prepare_snapshot(struct ploop_io * io, struct ploop_snapdata *sd)
{
	int err;
	struct file * file = io->files.file;

	file = dentry_open(dget(F_DENTRY(file)), mntget(F_MNT(file)), O_RDONLY|O_LARGEFILE, current_cred());
	if (IS_ERR(file))
		return PTR_ERR(file);

	/* Sanity checks */

	if (io->files.mapping != file->f_mapping ||
	    io->files.inode != file->f_mapping->host) {
		fput(file);
		return -EINVAL;
	}

	err = invalidate_inode_pages2(file->f_mapping);
	if (err) {
		fput(file);
		return err;
	}

	sd->file = file;
	return 0;
}
开发者ID:seyko2,项目名称:openvz_rhel6_kernel_mirror,代码行数:26,代码来源:io_nfs.c


示例10: autofs_dev_ioctl_open_mountpoint

/*
 * Open a file descriptor on the autofs mount point corresponding
 * to the given path and device number (aka. new_encode_dev(sb->s_dev)).
 */
static int autofs_dev_ioctl_open_mountpoint(const char *name, dev_t devid)
{
	int err, fd;

	fd = get_unused_fd();
	if (likely(fd >= 0)) {
		struct file *filp;
		struct path path;

		err = find_autofs_mount(name, &path, test_by_dev, &devid);
		if (err)
			goto out;

		/*
		 * Find autofs super block that has the device number
		 * corresponding to the autofs fs we want to open.
		 */

		filp = dentry_open(path.dentry, path.mnt, O_RDONLY,
				   current_cred());
		if (IS_ERR(filp)) {
			err = PTR_ERR(filp);
			goto out;
		}

		autofs_dev_ioctl_fd_install(fd, filp);
	}

	return fd;

out:
	put_unused_fd(fd);
	return err;
}
开发者ID:pierdebeer,项目名称:Audax_Kernel,代码行数:38,代码来源:dev-ioctl.c


示例11: big_key_read

/*
 * read the key data
 * - the key's semaphore is read-locked
 */
long big_key_read(const struct key *key, char __user *buffer, size_t buflen)
{
	size_t datalen = (size_t)key->payload.data[big_key_len];
	long ret;

	if (!buffer || buflen < datalen)
		return datalen;

	if (datalen > BIG_KEY_FILE_THRESHOLD) {
		struct path *path = (struct path *)&key->payload.data[big_key_path];
		struct file *file;
		loff_t pos;

		file = dentry_open(path, O_RDONLY, current_cred());
		if (IS_ERR(file))
			return PTR_ERR(file);

		pos = 0;
		ret = vfs_read(file, buffer, datalen, &pos);
		fput(file);
		if (ret >= 0 && ret != datalen)
			ret = -EIO;
	} else {
		ret = datalen;
		if (copy_to_user(buffer, key->payload.data[big_key_data],
				 datalen) != 0)
			ret = -EFAULT;
	}

	return ret;
}
开发者ID:020gzh,项目名称:linux,代码行数:35,代码来源:big_key.c


示例12: cr_dentry_open

/* Call dentry_open().
 * Caller should path_get() (or dget() and mntget()) just as they would for dentry_open().
 */
struct file *
cr_dentry_open(struct path *path, int flags)
{
    struct file *filp;

  #if !HAVE_TASK_CRED
    filp = dentry_open(path->dentry, path->mnt, flags);
  #elif HAVE_4_ARG_DENTRY_OPEN
    filp = dentry_open(path->dentry, path->mnt, flags, cr_current_cred());
  #elif HAVE_3_ARG_DENTRY_OPEN
    filp = dentry_open(path, flags, cr_current_cred());
    path_put(path); // dentry_open takes the ref count now
  #endif

    return filp;
}
开发者ID:Scorpio92,项目名称:mstar6a918,代码行数:19,代码来源:cr_io.c


示例13: cr_dentry_open

/* Call permision() and dentry_open().
 * Caller should dget() and mntget() just as they would for dentry_open(). */
struct file *
cr_dentry_open(struct dentry *dentry, struct vfsmount *mnt, int flags)
{
    struct file *filp;
    int acc_mask = ("\000\004\002\006"[(flags)&O_ACCMODE]); /* ICK (from linux/fs/namei.c) */
    int err;

    err = cr_permission(dentry->d_inode, acc_mask, NULL);
    filp = ERR_PTR(err);
  #if HAVE_TASK_CRED
    if (!IS_ERR(filp)) filp = dentry_open(dentry, mnt, flags, cr_current_cred());
  #else
    if (!IS_ERR(filp)) filp = dentry_open(dentry, mnt, flags);
  #endif

    return filp;
}
开发者ID:AvengerMoJo,项目名称:apc-8750,代码行数:19,代码来源:cr_io.c


示例14: ima_path_check

/**
 * ima_path_check - based on policy, collect/store measurement.
 * @path: contains a pointer to the path to be measured
 * @mask: contains MAY_READ, MAY_WRITE or MAY_EXECUTE
 *
 * Measure the file being open for readonly, based on the
 * ima_must_measure() policy decision.
 *
 * Keep read/write counters for all files, but only
 * invalidate the PCR for measured files:
 * 	- Opening a file for write when already open for read,
 *	  results in a time of measure, time of use (ToMToU) error.
 *	- Opening a file for read when already open for write,
 * 	  could result in a file measurement error.
 *
 * Always return 0 and audit dentry_open failures.
 * (Return code will be based upon measurement appraisal.)
 */
int ima_path_check(struct path *path, int mask, int update_counts)
{
	struct inode *inode = path->dentry->d_inode;
	struct ima_iint_cache *iint;
	struct file *file = NULL;
	int rc;

	if (!ima_initialized || !S_ISREG(inode->i_mode))
		return 0;
	iint = ima_iint_find_insert_get(inode);
	if (!iint)
		return 0;

	mutex_lock(&iint->mutex);
	if (update_counts)
		ima_update_counts(iint, mask);

	rc = ima_must_measure(iint, inode, MAY_READ, PATH_CHECK);
	if (rc < 0)
		goto out;

	if ((mask & MAY_WRITE) || (mask == 0))
		ima_read_write_check(TOMTOU, iint, inode,
				     path->dentry->d_name.name);

	if ((mask & (MAY_WRITE | MAY_READ | MAY_EXEC)) != MAY_READ)
		goto out;

	ima_read_write_check(OPEN_WRITERS, iint, inode,
			     path->dentry->d_name.name);
	if (!(iint->flags & IMA_MEASURED)) {
		struct dentry *dentry = dget(path->dentry);
		struct vfsmount *mnt = mntget(path->mnt);

		file = dentry_open(dentry, mnt, O_RDONLY | O_LARGEFILE,
				   current_cred());
		if (IS_ERR(file)) {
			int audit_info = 0;

			integrity_audit_msg(AUDIT_INTEGRITY_PCR, inode,
					    dentry->d_name.name,
					    "add_measurement",
					    "dentry_open failed",
					    1, audit_info);
			file = NULL;
			goto out;
		}
		rc = get_path_measurement(iint, file, dentry->d_name.name);
	}
out:
	mutex_unlock(&iint->mutex);
	if (file)
		fput(file);
	kref_put(&iint->refcount, iint_free);
	return 0;
}
开发者ID:AKToronto,项目名称:htc-kernel-msm7227,代码行数:74,代码来源:ima_main.c


示例15: big_key_read

/*
 * read the key data
 * - the key's semaphore is read-locked
 */
long big_key_read(const struct key *key, char __user *buffer, size_t buflen)
{
	size_t datalen = (size_t)key->payload.data[big_key_len];
	long ret;

	if (!buffer || buflen < datalen)
		return datalen;

	if (datalen > BIG_KEY_FILE_THRESHOLD) {
		struct path *path = (struct path *)&key->payload.data[big_key_path];
		struct file *file;
		u8 *data;
		u8 *enckey = (u8 *)key->payload.data[big_key_data];
		size_t enclen = ALIGN(datalen, crypto_skcipher_blocksize(big_key_skcipher));
		loff_t pos = 0;

		data = kmalloc(enclen, GFP_KERNEL);
		if (!data)
			return -ENOMEM;

		file = dentry_open(path, O_RDONLY, current_cred());
		if (IS_ERR(file)) {
			ret = PTR_ERR(file);
			goto error;
		}

		/* read file to kernel and decrypt */
		ret = kernel_read(file, data, enclen, &pos);
		if (ret >= 0 && ret != enclen) {
			ret = -EIO;
			goto err_fput;
		}

		ret = big_key_crypt(BIG_KEY_DEC, data, enclen, enckey);
		if (ret)
			goto err_fput;

		ret = datalen;

		/* copy decrypted data to user */
		if (copy_to_user(buffer, data, datalen) != 0)
			ret = -EFAULT;

err_fput:
		fput(file);
error:
		kfree(data);
	} else {
		ret = datalen;
		if (copy_to_user(buffer, key->payload.data[big_key_data],
				 datalen) != 0)
			ret = -EFAULT;
	}

	return ret;
}
开发者ID:mkrufky,项目名称:linux,代码行数:60,代码来源:big_key.c


示例16: LKTRTrace

/* common functions to regular file and dir */
struct file *hidden_open(struct dentry *dentry, aufs_bindex_t bindex, int flags)
{
	struct dentry *hidden_dentry;
	struct inode *hidden_inode;
	struct super_block *sb;
	struct vfsmount *hidden_mnt;
	struct file *hidden_file;
	struct aufs_branch *br;
	loff_t old_size;
	int udba;

	LKTRTrace("%.*s, b%d, flags 0%o\n", DLNPair(dentry), bindex, flags);
	DEBUG_ON(!dentry);
	hidden_dentry = au_h_dptr_i(dentry, bindex);
	DEBUG_ON(!hidden_dentry);
	hidden_inode = hidden_dentry->d_inode;
	DEBUG_ON(!hidden_inode);

	sb = dentry->d_sb;
	udba = au_flag_test(sb, AuFlag_UDBA_INOTIFY);
	if (unlikely(udba)) {
		// test here?
	}

	br = stobr(sb, bindex);
	br_get(br);
	/* drop flags for writing */
	if (test_ro(sb, bindex, dentry->d_inode))
		flags = au_file_roflags(flags);
	flags &= ~O_CREAT;
	spin_lock(&hidden_inode->i_lock);
	old_size = i_size_read(hidden_inode);
	spin_unlock(&hidden_inode->i_lock);

	//DbgSleep(3);

	dget(hidden_dentry);
	hidden_mnt = mntget(br->br_mnt);
	hidden_file = dentry_open(hidden_dentry, hidden_mnt, flags);
	//if (LktrCond) {fput(hidden_file); hidden_file = ERR_PTR(-1);}

	if (!IS_ERR(hidden_file)) {
#if 0 // remove this
		if (/* old_size && */ (flags & O_TRUNC)) {
			au_direval_dec(dentry);
			if (!IS_ROOT(dentry))
				au_direval_dec(dentry->d_parent);
		}
#endif
		return hidden_file;
	}

	br_put(br);
	TraceErrPtr(hidden_file);
	return hidden_file;
}
开发者ID:fullstory-morgue,项目名称:aufs,代码行数:57,代码来源:file.c


示例17: autofs4_dir_open

static int autofs4_dir_open(struct inode *inode, struct file *file)
{
    struct dentry *dentry = file->f_dentry;
    struct vfsmount *mnt = file->f_vfsmnt;
    struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
    int status;

    DPRINTK("file=%p dentry=%p %.*s",
            file, dentry, dentry->d_name.len, dentry->d_name.name);

    if (autofs4_oz_mode(sbi))
        goto out;

    if (autofs4_ispending(dentry)) {
        DPRINTK("dentry busy");
        return -EBUSY;
    }

    if (!d_mountpoint(dentry) && dentry->d_op && dentry->d_op->d_revalidate) {
        struct nameidata nd;
        int empty;

        /* In case there are stale directory dentrys from a failed mount */
        spin_lock(&dcache_lock);
        empty = list_empty(&dentry->d_subdirs);
        spin_unlock(&dcache_lock);

        if (!empty)
            d_invalidate(dentry);

        nd.flags = LOOKUP_DIRECTORY;
        status = (dentry->d_op->d_revalidate)(dentry, &nd);

        if (!status)
            return -ENOENT;
    }

    if (d_mountpoint(dentry)) {
        struct file *fp = NULL;
        struct vfsmount *fp_mnt = mntget(mnt);
        struct dentry *fp_dentry = dget(dentry);

        while (follow_down(&fp_mnt, &fp_dentry) && d_mountpoint(fp_dentry));

        fp = dentry_open(fp_dentry, fp_mnt, file->f_flags);
        status = PTR_ERR(fp);
        if (IS_ERR(fp)) {
            file->private_data = NULL;
            return status;
        }
        file->private_data = fp;
    }
out:
    return 0;
}
开发者ID:Dronevery,项目名称:JetsonTK1-kernel,代码行数:55,代码来源:root.c


示例18: ima_calc_file_hash

/*
 * ima_calc_file_hash - calculate file hash
 *
 * Asynchronous hash (ahash) allows using HW acceleration for calculating
 * a hash. ahash performance varies for different data sizes on different
 * crypto accelerators. shash performance might be better for smaller files.
 * The 'ima.ahash_minsize' module parameter allows specifying the best
 * minimum file size for using ahash on the system.
 *
 * If the ima.ahash_minsize parameter is not specified, this function uses
 * shash for the hash calculation.  If ahash fails, it falls back to using
 * shash.
 */
int ima_calc_file_hash(struct file *file, struct ima_digest_data *hash)
{
	loff_t i_size;
	int rc;
	struct file *f = file;
	bool new_file_instance = false, modified_flags = false;

	/*
	 * For consistency, fail file's opened with the O_DIRECT flag on
	 * filesystems mounted with/without DAX option.
	 */
	if (file->f_flags & O_DIRECT) {
		hash->length = hash_digest_size[ima_hash_algo];
		hash->algo = ima_hash_algo;
		return -EINVAL;
	}

	/* Open a new file instance in O_RDONLY if we cannot read */
	if (!(file->f_mode & FMODE_READ)) {
		int flags = file->f_flags & ~(O_WRONLY | O_APPEND |
				O_TRUNC | O_CREAT | O_NOCTTY | O_EXCL);
		flags |= O_RDONLY;
		f = dentry_open(&file->f_path, flags, file->f_cred);
		if (IS_ERR(f)) {
			/*
			 * Cannot open the file again, lets modify f_flags
			 * of original and continue
			 */
			pr_info_ratelimited("Unable to reopen file for reading.\n");
			f = file;
			f->f_flags |= FMODE_READ;
			modified_flags = true;
		} else {
			new_file_instance = true;
		}
	}

	i_size = i_size_read(file_inode(f));

	if (ima_ahash_minsize && i_size >= ima_ahash_minsize) {
		rc = ima_calc_file_ahash(f, hash);
		if (!rc)
			goto out;
	}

	rc = ima_calc_file_shash(f, hash);
out:
	if (new_file_instance)
		fput(f);
	else if (modified_flags)
		f->f_flags &= ~FMODE_READ;
	return rc;
}
开发者ID:markus-oberhumer,项目名称:linux,代码行数:66,代码来源:ima_crypto.c


示例19: __open_file

static int __open_file(struct inode *inode, struct file *file,
			struct dentry *parent)
{
	struct dentry *lower_dentry;
	struct file *lower_file;
	struct vfsmount *lower_mnt;
	struct dentry *dentry  = file->f_path.dentry;
	int lower_flags;
	int i = 0, idx = 0;
	for (i = 0; i <= 1; i++) {
		lower_dentry = wrapfs_lower_dentry_idx(dentry, i);
		if (!lower_dentry  || !lower_dentry->d_inode)
			continue;
		lower_flags = file->f_flags;

		if (lower_dentry->d_inode && (i == 1)) {
			UDBG;
			if (lower_flags & O_TRUNC) {
				int size = 0;
				int err = -EROFS;
				UDBG;

				err = copyup_file(parent->d_inode, file,
						  i, 0, size);
				if (!err)
					break;
				return err;
			} else
				lower_flags &= ~(OPEN_WRITE_FLAGS);
		}
		dget(lower_dentry);
		lower_mnt = mntget(wrapfs_lower_mnt_idx(dentry, i));

		if (!lower_mnt)
			lower_mnt = mntget(wrapfs_lower_mnt_idx(parent, i));

		lower_file = dentry_open(lower_dentry, lower_mnt, lower_flags,
					current_cred());

		if (IS_ERR(lower_file))
			return PTR_ERR(lower_file);

		wrapfs_set_lower_file(file, lower_file);
		branchget(inode->i_sb, i);
		idx = i;
		goto out;
	}
out:
	if (!wrapfs_lower_inode_idx(inode, idx))
		fsstack_copy_attr_all(inode,
			wrapfs_lower_inode_idx(inode, idx));
	return 0;
}
开发者ID:raghavendrasuvvari,项目名称:U2fs-FileSystem,代码行数:53,代码来源:file.c


示例20: dentry_open

struct file *vfsub_dentry_open(struct path *path, int flags)
{
	struct file *file;

	file = dentry_open(path, flags /* | __FMODE_NONOTIFY */,
			   current_cred());
	if (!IS_ERR_OR_NULL(file)
	    && (file->f_mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
		i_readcount_inc(path->dentry->d_inode);

	return file;
}
开发者ID:rice-american,项目名称:abuilds,代码行数:12,代码来源:vfsub.c



注:本文中的dentry_open函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ denyBasedOnTableName函数代码示例发布时间:2022-05-30
下一篇:
C++ density函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap