当前位置: 首页>>代码示例>>C++>>正文


C++ current_fsgid函数代码示例

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


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

示例1: tcmi_ctlfs_get_inode

/** 
 *  \<\<private\>\> A method for inode allocation.  Currently the uid
 * and gid is assigned based on the current's fsuid and fsgid. Block
 * size is not relevant, set to page size.  If the user doesn't
 * specify any inode or file operations, the default(empty operations,
 * but not NULL) assigned by the VFS will be kept.
 *
 * If the user specified a parent directory inode, it's access rights
 * are investigated and inherited by the new inode as follows:
 * - if the parent has the SGID bit set, parent's gid is assigned to
 * the new inode.
 * - a parent SGID bit is set on the new inode, if the new inode is a 
 * directory
 * 
 *
 * @param *dir - inode of the parent directory for the new inode
 * @param *sb - super block of the filesystem where the inode is
 * to be allocated
 * @param *mode - file type and access rights for the inode
 * @param *i_ops - inode operations
 * @param *f_ops - file operations (also stored in the new inode)
 * @return a pointer to the new inode or NULL
 */
static struct inode* tcmi_ctlfs_get_inode(struct inode *dir, 
					  struct super_block *sb, 
					  mode_t mode,
					  const struct inode_operations *i_ops,
					  const struct file_operations *f_ops)
{
	struct inode *inode = new_inode(sb);

	if (inode) {
		inode->i_mode = mode;
		inode->i_uid = current_fsuid();
		inode->i_gid = current_fsgid();
		inode->i_blocks = 0;
		inode->i_op  = (i_ops ? i_ops : inode->i_op);
		inode->i_fop = (f_ops ? f_ops : inode->i_fop);
		inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
		mdbg(INFO4, "New inode allocated, inode number = %ld", inode->i_ino);
		/* check parent inode's(if any) access rights */
		if (dir && (dir->i_mode & S_ISGID)) {
			inode->i_gid = dir->i_gid;
			if (S_ISDIR(mode))
				inode->i_mode |= S_ISGID;
		}

	}
	else
		minfo(ERR3, "Failed to allocate a new inode");

	return inode;
}
开发者ID:FIT-CVUT,项目名称:clondike,代码行数:53,代码来源:tcmi_ctlfs_entry.c

示例2: nfs_dq_reserve_inode

struct inode * nfs_dq_reserve_inode(struct inode * dir)
{
	struct inode * inode;
	struct nfs_inode *nfsi;

	/* Second, allocate "quota" inode and initialize required fields */
	inode = new_inode(dir->i_sb);
	if (inode == NULL)
		return ERR_PTR(-ENOMEM);

	nfsi = NFS_I(inode);
	nfsi->access_cache = RB_ROOT;
#ifdef CONFIG_NFS_FSCACHE
	nfsi->fscache = NULL;
#endif
	inode->i_uid = current_fsuid();
	inode->i_gid = current_fsgid();
	/* Is this optional? */
	if (dir->i_mode & S_ISGID)
		inode->i_gid = dir->i_gid;

	if (vfs_dq_alloc_inode(inode) == NO_QUOTA)
		goto err_drop;

	dprintk("NFS: DQ reserve inode (ino: %ld)\n", inode->i_ino);

	return inode;

err_drop:
	vfs_dq_drop(inode);
	inode->i_flags |= S_NOQUOTA;
	iput(inode);
	return ERR_PTR(-EDQUOT);
}
开发者ID:vps2fast,项目名称:openvz-kernel,代码行数:34,代码来源:quota.c

示例3: gfskdev_req_init_context

static void
gfskdev_req_init_context(struct gfskdev_req *req)
{
	req->in.h.uid = current_fsuid();
	req->in.h.gid = current_fsgid();
	req->in.h.pid = current->pid;
}
开发者ID:ddk50,项目名称:gfarm_v2,代码行数:7,代码来源:gfsk_devif.c

示例4: new_inode

/*
 * A single inode exists for all anon_inode files. Contrary to pipes,
 * anon_inode inodes have no associated per-instance data, so we need
 * only allocate one of them.
 */
static struct inode *anon_inode_mkinode(void)
{
	struct inode *inode = new_inode(anon_inode_mnt->mnt_sb);

	if (!inode)
		return ERR_PTR(-ENOMEM);

	inode->i_fop = &anon_inode_fops;

	inode->i_mapping->a_ops = &anon_aops;

	/*
	 * Mark the inode dirty from the very beginning,
	 * that way it will never be moved to the dirty
	 * list because mark_inode_dirty() will think
	 * that it already _is_ on the dirty list.
	 */
	inode->i_state = I_DIRTY;
	inode->i_mode = S_IRUSR | S_IWUSR;
	inode->i_uid = current_fsuid();
	inode->i_gid = current_fsgid();
	inode->i_flags |= S_PRIVATE;
	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
	return inode;
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:30,代码来源:anon_inodes.c

示例5: new_inode

struct inode *samplefs_get_inode(struct super_block *sb, int mode, dev_t dev)
{
        struct inode * inode = new_inode(sb);

        if (inode) {
                inode->i_mode = mode;
                inode->i_uid = current_fsuid();
                inode->i_gid = current_fsgid();
                inode->i_blocks = 0;
                inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
                switch (mode & S_IFMT) {
                default:
			init_special_inode(inode, mode, dev);
			break;
/* We are not ready to handle files yet */
/*                case S_IFREG:
			inode->i_op = &sfs_file_inode_operations;
			break; */
                case S_IFDIR:
                        inode->i_op = &simple_dir_inode_operations;

                        /* link == 2 (for initial ".." and "." entries) */
                        inc_nlink(inode);
                        break;
                }
        }
        return inode;
	
}
开发者ID:Andiry,项目名称:Sample-FS,代码行数:29,代码来源:super.c

示例6: mdc_setattr_pack_rec

static void mdc_setattr_pack_rec(struct mdt_rec_setattr *rec,
				 struct md_op_data *op_data)
{
	rec->sa_opcode  = REINT_SETATTR;
	rec->sa_fsuid   = from_kuid(&init_user_ns, current_fsuid());
	rec->sa_fsgid   = from_kgid(&init_user_ns, current_fsgid());
	rec->sa_cap     = cfs_curproc_cap_pack();
	rec->sa_suppgid = -1;

	rec->sa_fid    = op_data->op_fid1;
	rec->sa_valid  = attr_pack(op_data->op_attr.ia_valid);
	rec->sa_mode   = op_data->op_attr.ia_mode;
	rec->sa_uid    = from_kuid(&init_user_ns, op_data->op_attr.ia_uid);
	rec->sa_gid    = from_kgid(&init_user_ns, op_data->op_attr.ia_gid);
	rec->sa_size   = op_data->op_attr.ia_size;
	rec->sa_blocks = op_data->op_attr_blocks;
	rec->sa_atime  = LTIME_S(op_data->op_attr.ia_atime);
	rec->sa_mtime  = LTIME_S(op_data->op_attr.ia_mtime);
	rec->sa_ctime  = LTIME_S(op_data->op_attr.ia_ctime);
	rec->sa_attr_flags = ((struct ll_iattr *)&op_data->op_attr)->ia_attr_flags;
	if ((op_data->op_attr.ia_valid & ATTR_GID) &&
	    in_group_p(op_data->op_attr.ia_gid))
		rec->sa_suppgid =
			from_kgid(&init_user_ns, op_data->op_attr.ia_gid);
	else
		rec->sa_suppgid = op_data->op_suppgids[0];

	rec->sa_bias = op_data->op_bias;
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:29,代码来源:mdc_lib.c

示例7: cifs_mknod

int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
		dev_t device_number)
{
	int rc = -EPERM;
	int xid;
	int create_options = CREATE_NOT_DIR | CREATE_OPTION_SPECIAL;
	struct cifs_sb_info *cifs_sb;
	struct tcon_link *tlink;
	struct cifsTconInfo *pTcon;
	char *full_path = NULL;
	struct inode *newinode = NULL;

	if (!old_valid_dev(device_number))
		return -EINVAL;

	cifs_sb = CIFS_SB(inode->i_sb);
	tlink = cifs_sb_tlink(cifs_sb);
	if (IS_ERR(tlink))
		return PTR_ERR(tlink);

	pTcon = tlink_tcon(tlink);

	xid = GetXid();

	full_path = build_path_from_dentry(direntry);
	if (full_path == NULL)
		rc = -ENOMEM;
	else if (pTcon->unix_ext) {
		struct cifs_unix_set_info_args args = {
			.mode	= mode & ~current_umask(),
			.ctime	= NO_CHANGE_64,
			.atime	= NO_CHANGE_64,
			.mtime	= NO_CHANGE_64,
			.device	= device_number,
		};
		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
			args.uid = (__u64) current_fsuid();
			args.gid = (__u64) current_fsgid();
		} else {
			args.uid = NO_CHANGE_64;
			args.gid = NO_CHANGE_64;
		}
		rc = CIFSSMBUnixSetPathInfo(xid, pTcon, full_path, &args,
					    cifs_sb->local_nls,
					    cifs_sb->mnt_cifs_flags &
						CIFS_MOUNT_MAP_SPECIAL_CHR);

		if (!rc) {
			rc = cifs_get_inode_info_unix(&newinode, full_path,
						inode->i_sb, xid);
			if (pTcon->nocase)
				direntry->d_op = &cifs_ci_dentry_ops;
			else
				direntry->d_op = &cifs_dentry_ops;
			if (rc == 0)
				d_instantiate(direntry, newinode);
		}
	} else {
		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
开发者ID:vps2fast,项目名称:openvz-kernel,代码行数:59,代码来源:dir.c

示例8: F2FS_SB

static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
{
	struct super_block *sb = dir->i_sb;
	struct f2fs_sb_info *sbi = F2FS_SB(sb);
	nid_t ino;
	struct inode *inode;
	bool nid_free = false;
	int err;

	inode = new_inode(sb);
	if (!inode)
		return ERR_PTR(-ENOMEM);

	f2fs_lock_op(sbi);
	if (!alloc_nid(sbi, &ino)) {
		f2fs_unlock_op(sbi);
		err = -ENOSPC;
		goto fail;
	}
	f2fs_unlock_op(sbi);

	inode->i_uid = current_fsuid();

	if (dir->i_mode & S_ISGID) {
		inode->i_gid = dir->i_gid;
		if (S_ISDIR(mode))
			mode |= S_ISGID;
	} else {
		inode->i_gid = current_fsgid();
	}

	inode->i_ino = ino;
	inode->i_mode = mode;
	inode->i_blocks = 0;
	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME;
	inode->i_generation = sbi->s_next_generation++;

	err = insert_inode_locked(inode);
	if (err) {
		err = -EINVAL;
		nid_free = true;
		goto out;
	}
	trace_f2fs_new_inode(inode, 0);
	mark_inode_dirty(inode);
	return inode;

out:
	clear_nlink(inode);
	unlock_new_inode(inode);
fail:
	trace_f2fs_new_inode(inode, err);
	make_bad_inode(inode);
	iput(inode);
	if (nid_free)
		alloc_nid_failed(sbi, ino);
	return ERR_PTR(err);
}
开发者ID:7799,项目名称:linux,代码行数:58,代码来源:namei.c

示例9: v9fs_get_fsgid_for_create

static kgid_t v9fs_get_fsgid_for_create(struct inode *dir_inode)
{
	BUG_ON(dir_inode == NULL);

	if (dir_inode->i_mode & S_ISGID) {
		/* set_gid bit is set.*/
		return dir_inode->i_gid;
	}
	return current_fsgid();
}
开发者ID:morristech,项目名称:linux,代码行数:10,代码来源:vfs_inode_dotl.c

示例10: __mdc_pack_body

static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid)
{
	LASSERT (b != NULL);

	b->suppgid = suppgid;
	b->uid = from_kuid(&init_user_ns, current_uid());
	b->gid = from_kgid(&init_user_ns, current_gid());
	b->fsuid = from_kuid(&init_user_ns, current_fsuid());
	b->fsgid = from_kgid(&init_user_ns, current_fsgid());
	b->capability = cfs_curproc_cap_pack();
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:11,代码来源:mdc_lib.c

示例11: mdc_open_pack

/* packing of MDS records */
void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
		   umode_t mode, __u64 rdev, __u64 flags, const void *lmm,
		   size_t lmmlen)
{
	struct mdt_rec_create *rec;
	char *tmp;
	__u64 cr_flags;

	CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create));
	rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);

	/* XXX do something about time, uid, gid */
	rec->cr_opcode = REINT_OPEN;
	rec->cr_fsuid	= from_kuid(&init_user_ns, current_fsuid());
	rec->cr_fsgid	= from_kgid(&init_user_ns, current_fsgid());
	rec->cr_cap    = cfs_curproc_cap_pack();
	rec->cr_mode   = mode;
	cr_flags	= mds_pack_open_flags(flags);
	rec->cr_rdev   = rdev;
	rec->cr_umask  = current_umask();
	if (op_data != NULL) {
		rec->cr_fid1       = op_data->op_fid1;
		rec->cr_fid2       = op_data->op_fid2;
		rec->cr_time       = op_data->op_mod_time;
		rec->cr_suppgid1   = op_data->op_suppgids[0];
		rec->cr_suppgid2   = op_data->op_suppgids[1];
		rec->cr_bias       = op_data->op_bias;
		rec->cr_open_handle_old = op_data->op_open_handle;

		if (op_data->op_name) {
			mdc_pack_name(req, &RMF_NAME, op_data->op_name,
				      op_data->op_namelen);

			if (op_data->op_bias & MDS_CREATE_VOLATILE)
				cr_flags |= MDS_OPEN_VOLATILE;
		}

		mdc_file_secctx_pack(req, op_data->op_file_secctx_name,
				     op_data->op_file_secctx,
				     op_data->op_file_secctx_size);

		/* pack SELinux policy info if any */
		mdc_file_sepol_pack(req);
	}

	if (lmm) {
		cr_flags |= MDS_OPEN_HAS_EA;
		tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
		memcpy(tmp, lmm, lmmlen);
	}
	set_mrc_cr_flags(rec, cr_flags);
}
开发者ID:Xyratex,项目名称:lustre-stable,代码行数:53,代码来源:mdc_lib.c

示例12: mknod_ptmx

static int mknod_ptmx(struct super_block *sb)
{
	int mode;
	int rc = -ENOMEM;
	struct dentry *dentry;
	struct inode *inode;
	struct dentry *root = sb->s_root;
	struct pts_fs_info *fsi = DEVPTS_SB(sb);
	struct pts_mount_opts *opts = &fsi->mount_opts;
	kuid_t ptmx_uid = current_fsuid();
	kgid_t ptmx_gid = current_fsgid();

	inode_lock(d_inode(root));

	/* If we have already created ptmx node, return */
	if (fsi->ptmx_dentry) {
		rc = 0;
		goto out;
	}

	dentry = d_alloc_name(root, "ptmx");
	if (!dentry) {
		pr_err("Unable to alloc dentry for ptmx node\n");
		goto out;
	}

	/*
	 * Create a new 'ptmx' node in this mount of devpts.
	 */
	inode = new_inode(sb);
	if (!inode) {
		pr_err("Unable to alloc inode for ptmx node\n");
		dput(dentry);
		goto out;
	}

	inode->i_ino = 2;
	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);

	mode = S_IFCHR|opts->ptmxmode;
	init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2));
	inode->i_uid = ptmx_uid;
	inode->i_gid = ptmx_gid;

	d_add(dentry, inode);

	fsi->ptmx_dentry = dentry;
	rc = 0;
out:
	inode_unlock(d_inode(root));
	return rc;
}
开发者ID:guribe94,项目名称:linux,代码行数:52,代码来源:inode.c

示例13: push_ctxt

/* push / pop to root of obd store */
void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
	       struct lvfs_ucred *uc)
{
	/* if there is underlaying dt_device then push_ctxt is not needed */
	if (new_ctx->dt != NULL)
		return;

	/* ASSERT_NOT_KERNEL_CTXT("already in kernel context!\n"); */
	ASSERT_CTXT_MAGIC(new_ctx->magic);
	OBD_SET_CTXT_MAGIC(save);

	save->fs = get_fs();
	LASSERT(d_count(cfs_fs_pwd(current->fs)));
	LASSERT(d_count(new_ctx->pwd));
	save->pwd = dget(cfs_fs_pwd(current->fs));
	save->pwdmnt = mntget(cfs_fs_mnt(current->fs));
	save->luc.luc_umask = current_umask();
	save->ngroups = current_cred()->group_info->ngroups;

	LASSERT(save->pwd);
	LASSERT(save->pwdmnt);
	LASSERT(new_ctx->pwd);
	LASSERT(new_ctx->pwdmnt);

	if (uc) {
		struct cred *cred;
		save->luc.luc_uid = current_uid();
		save->luc.luc_gid = current_gid();
		save->luc.luc_fsuid = current_fsuid();
		save->luc.luc_fsgid = current_fsgid();
		save->luc.luc_cap = current_cap();

		cred = prepare_creds();
		if (cred) {
			cred->uid = uc->luc_uid;
			cred->gid = uc->luc_gid;
			cred->fsuid = uc->luc_fsuid;
			cred->fsgid = uc->luc_fsgid;
			cred->cap_effective = uc->luc_cap;
			commit_creds(cred);
		}

		push_group_info(save,
				uc->luc_ginfo ?:
				uc->luc_identity ? uc->luc_identity->mi_ginfo :
						   NULL);
	}
	current->fs->umask = 0; /* umask already applied on client */
	set_fs(new_ctx->fs);
	ll_set_fs_pwd(current->fs, new_ctx->pwdmnt, new_ctx->pwd);
}
开发者ID:7799,项目名称:linux,代码行数:52,代码来源:lvfs_linux.c

示例14: mdc_open_pack

/* packing of MDS records */
void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
		   umode_t mode, __u64 rdev, __u64 flags, const void *lmm,
		   size_t lmmlen)
{
	struct mdt_rec_create *rec;
	char *tmp;
	__u64 cr_flags;

	CLASSERT(sizeof(struct mdt_rec_reint) == sizeof(struct mdt_rec_create));
	rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);

	/* XXX do something about time, uid, gid */
	rec->cr_opcode = REINT_OPEN;
	rec->cr_fsuid	= from_kuid(&init_user_ns, current_fsuid());
	rec->cr_fsgid	= from_kgid(&init_user_ns, current_fsgid());
	rec->cr_cap    = cfs_curproc_cap_pack();
	rec->cr_mode   = mode;
	cr_flags	= mds_pack_open_flags(flags);
	rec->cr_rdev   = rdev;
	rec->cr_umask  = current_umask();
	if (op_data != NULL) {
		rec->cr_fid1       = op_data->op_fid1;
		rec->cr_fid2       = op_data->op_fid2;
		rec->cr_time       = op_data->op_mod_time;
		rec->cr_suppgid1   = op_data->op_suppgids[0];
		rec->cr_suppgid2   = op_data->op_suppgids[1];
		rec->cr_bias       = op_data->op_bias;
		rec->cr_old_handle = op_data->op_handle;

		mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
		/* the next buffer is child capa, which is used for replay,
		 * will be packed from the data in reply message. */

		if (op_data->op_name) {
			mdc_pack_name(req, &RMF_NAME, op_data->op_name,
				      op_data->op_namelen);

			if (op_data->op_bias & MDS_CREATE_VOLATILE)
				cr_flags |= MDS_OPEN_VOLATILE;
		}
	}

	if (lmm) {
		cr_flags |= MDS_OPEN_HAS_EA;
		tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
		memcpy(tmp, lmm, lmmlen);
	}
	set_mrc_cr_flags(rec, cr_flags);
}
开发者ID:Zealsathish,项目名称:lustre,代码行数:50,代码来源:mdc_lib.c

示例15: orangefs_handle_hash

/*
 * Allocate an inode for a newly created file and insert it into the inode hash.
 */
struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir,
		int mode, dev_t dev, struct orangefs_object_kref *ref)
{
	unsigned long hash = orangefs_handle_hash(ref);
	struct inode *inode;
	int error;

	gossip_debug(GOSSIP_INODE_DEBUG,
		     "%s:(sb is %p | MAJOR(dev)=%u | MINOR(dev)=%u mode=%o)\n",
		     __func__,
		     sb,
		     MAJOR(dev),
		     MINOR(dev),
		     mode);

	inode = new_inode(sb);
	if (!inode)
		return NULL;

	orangefs_set_inode(inode, ref);
	inode->i_ino = hash;	/* needed for stat etc */

	error = orangefs_inode_getattr(inode, 1, 1);
	if (error)
		goto out_iput;

	orangefs_init_iops(inode);

	inode->i_mode = mode;
	inode->i_uid = current_fsuid();
	inode->i_gid = current_fsgid();
	inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
	inode->i_size = PAGE_SIZE;
	inode->i_rdev = dev;

	error = insert_inode_locked4(inode, hash, orangefs_test_inode, ref);
	if (error < 0)
		goto out_iput;

	gossip_debug(GOSSIP_INODE_DEBUG,
		     "Initializing ACL's for inode %pU\n",
		     get_khandle_from_ino(inode));
	orangefs_init_acl(inode, dir);
	return inode;

out_iput:
	iput(inode);
	return ERR_PTR(error);
}
开发者ID:acton393,项目名称:linux,代码行数:52,代码来源:inode.c


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