本文整理汇总了C++中pid_nr函数的典型用法代码示例。如果您正苦于以下问题:C++ pid_nr函数的具体用法?C++ pid_nr怎么用?C++ pid_nr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pid_nr函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: enable_signals
static int enable_signals(struct r3964_info *pInfo, struct pid *pid, int arg)
{
struct r3964_client_info *pClient;
struct r3964_client_info **ppClient;
struct r3964_message *pMsg;
if ((arg & R3964_SIG_ALL) == 0) {
/* Remove client from client list */
for (ppClient = &pInfo->firstClient; *ppClient;
ppClient = &(*ppClient)->next) {
pClient = *ppClient;
if (pClient->pid == pid) {
TRACE_PS("removing client %d from client list",
pid_nr(pid));
*ppClient = pClient->next;
while (pClient->msg_count) {
pMsg = remove_msg(pInfo, pClient);
if (pMsg) {
kfree(pMsg);
TRACE_M("enable_signals - msg "
"kfree %p", pMsg);
}
}
put_pid(pClient->pid);
kfree(pClient);
TRACE_M("enable_signals - kfree %p", pClient);
return 0;
}
}
return -EINVAL;
} else {
pClient = findClient(pInfo, pid);
if (pClient) {
/* update signal options */
pClient->sig_flags = arg;
} else {
/* add client to client list */
pClient = kmalloc(sizeof(struct r3964_client_info),
GFP_KERNEL);
TRACE_M("enable_signals - kmalloc %p", pClient);
if (pClient == NULL)
return -ENOMEM;
TRACE_PS("add client %d to client list", pid_nr(pid));
spin_lock_init(&pClient->lock);
pClient->sig_flags = arg;
pClient->pid = get_pid(pid);
pClient->next = pInfo->firstClient;
pClient->first_msg = NULL;
pClient->last_msg = NULL;
pClient->next_block_to_read = NULL;
pClient->msg_count = 0;
pInfo->firstClient = pClient;
}
}
return 0;
}
开发者ID:ManiacTwister,项目名称:linux-hnd,代码行数:59,代码来源:n_r3964.c
示例2: ugidctl_setgid
static long ugidctl_setgid(struct ugidctl_context *ctx, void __user *arg)
{
struct ugidctl_setid_rq req;
enum pid_type ptype;
struct cred *cred;
gid_t gid;
pid_t pid;
long rc;
if (copy_from_user(&req, arg, sizeof(req)))
return -EFAULT;
gid = req.gid;
if (capable(CAP_SETUID))
return ugidctl_sys_setgid(gid);
if (memcmp(ctx->key, req.key, sizeof(ctx->key)))
return -EPERM;
mutex_lock(&ctx->lock);
if (ugidctl_find_gid(ctx, gid)) {
mutex_unlock(&ctx->lock);
return -EPERM;
}
ptype = ctx->ptype;
pid = ctx->pid;
mutex_unlock(&ctx->lock);
if (pid != pid_nr(get_task_pid(current, ptype)))
return -EPERM;
cred = prepare_creds();
if (!cred)
return -ENOMEM;
cap_raise(cred->cap_effective, CAP_SETGID);
commit_creds(cred);
rc = ugidctl_sys_setgid(gid);
cred = prepare_creds();
if (!cred) {
/* unable to restore process capabilities - kill process */
do_exit(SIGKILL);
return -ENOMEM;
}
cap_lower(cred->cap_effective, CAP_SETGID);
commit_creds(cred);
return rc;
}
开发者ID:004helix,项目名称:ugidctl,代码行数:58,代码来源:ugidctl-dev.c
示例3: NameServerDrv_close
/*
* ======== NameServerDrv_close ========
*
* Linux specific function to close the driver.
*/
int NameServerDrv_close(struct inode *inode, struct file *filp)
{
pid_t pid;
/* release resources abandoned by the process */
pid = pid_nr(filp->f_owner.pid);
NameServerDrv_releaseResources(pid);
return(0);
}
开发者ID:yesj,项目名称:J5_A8,代码行数:15,代码来源:NameServerDrv.c
示例4: ecryptfs_send_netlink
/**
* ecryptfs_send_netlink
* @data: The data to include as the payload
* @data_len: The byte count of the data
* @msg_ctx: The netlink context that will be used to handle the
* response message
* @msg_type: The type of netlink message to send
* @msg_flags: The flags to include in the netlink header
* @daemon_pid: The process id of the daemon to send the message to
*
* Sends the data to the specified daemon pid and uses the netlink
* context element to store the data needed for validation upon
* receiving the response. The data and the netlink context can be
* null if just sending a netlink header is sufficient. Returns zero
* upon sending the message; non-zero upon error.
*/
int ecryptfs_send_netlink(char *data, int data_len,
struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
u16 msg_flags, struct pid *daemon_pid)
{
struct sk_buff *skb;
struct nlmsghdr *nlh;
struct ecryptfs_message *msg;
size_t payload_len;
int rc;
payload_len = ((data && data_len) ? (sizeof(*msg) + data_len) : 0);
skb = alloc_skb(NLMSG_SPACE(payload_len), GFP_KERNEL);
if (!skb) {
rc = -ENOMEM;
ecryptfs_printk(KERN_ERR, "Failed to allocate socket buffer\n");
goto out;
}
nlh = NLMSG_PUT(skb, pid_nr(daemon_pid), msg_ctx ? msg_ctx->counter : 0,
msg_type, payload_len);
nlh->nlmsg_flags = msg_flags;
if (msg_ctx && payload_len) {
msg = (struct ecryptfs_message *)NLMSG_DATA(nlh);
msg->index = msg_ctx->index;
msg->data_len = data_len;
memcpy(msg->data, data, data_len);
}
rc = netlink_unicast(ecryptfs_nl_sock, skb, pid_nr(daemon_pid), 0);
if (rc < 0) {
ecryptfs_printk(KERN_ERR, "Failed to send eCryptfs netlink "
"message; rc = [%d]\n", rc);
goto out;
}
rc = 0;
goto out;
nlmsg_failure:
rc = -EMSGSIZE;
kfree_skb(skb);
out:
return rc;
}
开发者ID:LouZiffer,项目名称:m900_kernel_cupcake-SDX,代码行数:56,代码来源:netlink.c
示例5: remove_client_block
static void remove_client_block(struct r3964_info *pInfo,
struct r3964_client_info *pClient)
{
struct r3964_block_header *block;
TRACE_PS("remove_client_block PID %d", pid_nr(pClient->pid));
block = pClient->next_block_to_read;
if (block) {
block->locks--;
if (block->locks == 0) {
remove_from_rx_queue(pInfo, block);
}
}
pClient->next_block_to_read = NULL;
}
开发者ID:ManiacTwister,项目名称:linux-hnd,代码行数:16,代码来源:n_r3964.c
示例6: ugidctl_setpidchktype
static long ugidctl_setpidchktype(struct ugidctl_context *ctx,
unsigned long arg)
{
enum pid_type ptype;
pid_t pid;
long rc;
switch (arg) {
case UGIDCTL_PIDTYPE_PID:
ptype = PIDTYPE_PID;
break;
case UGIDCTL_PIDTYPE_PGID:
ptype = PIDTYPE_PGID;
break;
case UGIDCTL_PIDTYPE_SID:
ptype = PIDTYPE_SID;
break;
default:
return -EINVAL;
}
pid = pid_nr(get_task_pid(current, ptype));
mutex_lock(&ctx->lock);
switch (ctx->ptype) {
case PIDTYPE_PID:
rc = UGIDCTL_PIDTYPE_PID;
break;
case PIDTYPE_PGID:
rc = UGIDCTL_PIDTYPE_PGID;
break;
case PIDTYPE_SID:
rc = UGIDCTL_PIDTYPE_SID;
break;
default:
mutex_unlock(&ctx->lock);
return -EINVAL;
}
ctx->ptype = ptype;
ctx->pid = pid;
mutex_unlock(&ctx->lock);
return rc;
}
开发者ID:004helix,项目名称:ugidctl,代码行数:47,代码来源:ugidctl-dev.c
示例7: ugidctl_open
static int ugidctl_open(struct inode *inode, struct file *filp)
{
struct ugidctl_context *ctx;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
mutex_init(&ctx->lock);
ctx->pid = pid_nr(get_task_pid(current, PIDTYPE_PID));
ctx->ptype = PIDTYPE_PID;
get_random_bytes(ctx->key, sizeof(ctx->key));
ctx->uids = RB_ROOT;
ctx->gids = RB_ROOT;
ctx->uids_total = 0;
ctx->gids_total = 0;
filp->private_data = ctx;
return 0;
}
开发者ID:004helix,项目名称:ugidctl,代码行数:24,代码来源:ugidctl-dev.c
示例8: ERR_PTR
//.........这里部分代码省略.........
/*
* Clear TID on mm_release()?
*/
p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr : NULL;
#ifdef CONFIG_BLOCK
p->plug = NULL;
#endif
#ifdef CONFIG_FUTEX
p->robust_list = NULL;
#ifdef CONFIG_COMPAT
p->compat_robust_list = NULL;
#endif
INIT_LIST_HEAD(&p->pi_state_list);
p->pi_state_cache = NULL;
#endif
/*
* sigaltstack should be cleared when sharing the same VM
*/
if ((clone_flags & (CLONE_VM|CLONE_VFORK)) == CLONE_VM)
p->sas_ss_sp = p->sas_ss_size = 0;
/*
* Syscall tracing and stepping should be turned off in the
* child regardless of CLONE_PTRACE.
*/
user_disable_single_step(p);
clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE);
#ifdef TIF_SYSCALL_EMU
clear_tsk_thread_flag(p, TIF_SYSCALL_EMU);
#endif
clear_all_latency_tracing(p);
/* ok, now we should be set up.. */
p->pid = pid_nr(pid);
if (clone_flags & CLONE_THREAD) {
p->exit_signal = -1;
p->group_leader = current->group_leader;
p->tgid = current->tgid;
} else {
if (clone_flags & CLONE_PARENT)
p->exit_signal = current->group_leader->exit_signal;
else
p->exit_signal = (clone_flags & CSIGNAL);
p->group_leader = p;
p->tgid = p->pid;
}
p->nr_dirtied = 0;
p->nr_dirtied_pause = 128 >> (PAGE_SHIFT - 10);
p->dirty_paused_when = 0;
p->pdeath_signal = 0;
INIT_LIST_HEAD(&p->thread_group);
p->task_works = NULL;
/*
* Make it visible to the rest of the system, but dont wake it up yet.
* Need tasklist lock for parent etc handling!
*/
write_lock_irq(&tasklist_lock);
/* CLONE_PARENT re-uses the old parent */
if (clone_flags & (CLONE_PARENT|CLONE_THREAD)) {
p->real_parent = current->real_parent;
p->parent_exec_id = current->parent_exec_id;
} else {
开发者ID:19Dan01,项目名称:linux,代码行数:67,代码来源:fork.c
示例9: sys_setpgid
/*
* This needs some heavy checking ...
* I just haven't the stomach for it. I also don't fully
* understand sessions/pgrp etc. Let somebody who does explain it.
*
* OK, I think I have the protection semantics right.... this is really
* only important on a multi-user system anyway, to make sure one user
* can't send a signal to a process owned by another. -TYT, 12/12/91
*
* Auch. Had to add the 'did_exec' flag to conform completely to POSIX.
* LBT 04.03.94
*/
asmlinkage long sys_setpgid(pid_t pid, pid_t pgid)
{
struct task_struct *p;
struct task_struct *group_leader = current->group_leader;
struct pid *pgrp;
int err;
if (!pid)
pid = task_pid_vnr(group_leader);
if (!pgid)
pgid = pid;
if (pgid < 0)
return -EINVAL;
/* From this point forward we keep holding onto the tasklist lock
* so that our parent does not change from under us. -DaveM
*/
write_lock_irq(&tasklist_lock);
err = -ESRCH;
p = find_task_by_vpid(pid);
if (!p)
goto out;
err = -EINVAL;
if (!thread_group_leader(p))
goto out;
if (same_thread_group(p->real_parent, group_leader)) {
err = -EPERM;
if (task_session(p) != task_session(group_leader))
goto out;
err = -EACCES;
if (p->did_exec)
goto out;
} else {
err = -ESRCH;
if (p != group_leader)
goto out;
}
err = -EPERM;
if (p->signal->leader)
goto out;
pgrp = task_pid(p);
if (pgid != pid) {
struct task_struct *g;
pgrp = find_vpid(pgid);
g = pid_task(pgrp, PIDTYPE_PGID);
if (!g || task_session(g) != task_session(group_leader))
goto out;
}
err = security_task_setpgid(p, pgid);
if (err)
goto out;
if (task_pgrp(p) != pgrp) {
change_pid(p, PIDTYPE_PGID, pgrp);
set_task_pgrp(p, pid_nr(pgrp));
}
err = 0;
out:
/* All paths lead to here, thus we are safe. -DaveM */
write_unlock_irq(&tasklist_lock);
return err;
}
开发者ID:maraz,项目名称:linux-2.6,代码行数:82,代码来源:sys.c
示例10: NameServerDrv_ioctl
/*
* ======== NameServerDrv_ioctl ========
*
*/
static long NameServerDrv_ioctl(struct file *filp, unsigned int cmd,
unsigned long args)
{
int osStatus = 0;
Int32 status = NameServer_S_SUCCESS;
Int32 ret;
NameServerDrv_CmdArgs cargs;
Osal_Pid pid;
GT_3trace(curTrace, GT_ENTER, "NameServerDrv_ioctl", filp, cmd, args);
/* save the process id for resource tracking */
pid = pid_nr(filp->f_owner.pid);
/* copy the full args from user space */
ret = copy_from_user(&cargs, (Ptr)args, sizeof(NameServerDrv_CmdArgs));
GT_assert(curTrace, (ret == 0));
switch (cmd) {
case CMD_NAMESERVER_ADD: {
NameServerDrv_Res * res = NULL;
Ptr buf;
/* allocate resource tracker object */
res = Memory_alloc(NULL, sizeof(NameServerDrv_Res), 0, NULL);
if (res == NULL) {
status = NameServer_E_MEMORY;
GT_setFailureReason(curTrace, GT_4CLASS,
"NameServerDrv_ioctl", status, "out of memory");
}
/* allocate memory for the name */
if (status == NameServer_S_SUCCESS) {
res->args.add.len = cargs.args.add.nameLen;
res->args.add.name = Memory_alloc(NULL,
cargs.args.add.nameLen, 0, NULL);
if (res->args.add.name == NULL) {
status = NameServer_E_MEMORY;
GT_setFailureReason(curTrace, GT_4CLASS,
"NameServerDrv_ioctl", status, "out of memory");
}
}
/* copy the name from user memory */
if (status == NameServer_S_SUCCESS) {
status = copy_from_user(res->args.add.name,
cargs.args.add.name, cargs.args.add.nameLen);
if (status != 0) {
GT_setFailureReason(curTrace, GT_4CLASS,
"NameServerDrv_ioctl", status,
"copy_from_user failed");
status = NameServer_E_OSFAILURE;
osStatus = -EFAULT;
}
}
/* allocate memory for the buf */
if (status == NameServer_S_SUCCESS) {
buf = Memory_alloc(NULL, cargs.args.add.len, 0, NULL);
if (buf == NULL) {
status = NameServer_E_MEMORY;
GT_setFailureReason(curTrace, GT_4CLASS,
"NameServerDrv_ioctl", status, "out of memory");
}
}
/* copy the value from user buf */
if (status == NameServer_S_SUCCESS) {
status = copy_from_user(buf, cargs.args.add.buf,
cargs.args.add.len);
if (status != 0) {
GT_setFailureReason(curTrace, GT_4CLASS,
"NameServerDrv_ioctl", status,
"copy_from_user failed");
status = NameServer_E_OSFAILURE;
osStatus = -EFAULT;
}
}
/* invoke the module api */
if (status == NameServer_S_SUCCESS) {
cargs.args.add.entry = NameServer_add(cargs.args.add.handle,
res->args.add.name, buf, cargs.args.add.len);
if (cargs.args.addUInt32.entry == NULL) {
status = NameServer_E_FAIL;
GT_setFailureReason(curTrace, GT_4CLASS,
"NameServerDrv_ioctl", status,
"NameServer_addUInt32 failed");
}
}
//.........这里部分代码省略.........
开发者ID:yesj,项目名称:J5_A8,代码行数:101,代码来源:NameServerDrv.c
示例11: _sis1100_irq_thread
static void
_sis1100_irq_thread(struct sis1100_softc* sc, enum handlercomm command)
{
u_int32_t new_irqs=0;
int i;
mutex_lock(&sc->sem_irqinfo);
if (command&handlercomm_doorbell) {
DECLARE_SPINLOCKFLAGS(flags)
u_int32_t doorbell;
SPIN_LOCK_IRQSAVE(sc->lock_doorbell, flags);
doorbell=sc->doorbell;
sc->doorbell=0;
SPIN_UNLOCK_IRQRESTORE(sc->lock_doorbell, flags);
switch (sc->remote_hw) {
case sis1100_hw_vme:
new_irqs|=sis3100rem_irq_handler(sc, doorbell);
break;
case sis1100_hw_camac:
new_irqs|=sis5100rem_irq_handler(sc, doorbell);
break;
case sis1100_hw_pci:
/* do nothing */
break;
case sis1100_hw_lvd:
new_irqs|=zellvd_rem_irq_handler(sc, doorbell);
break;
case sis1100_hw_pandapixel:
new_irqs|=pandapixel_rem_irq_handler(sc, doorbell);
break;
case sis1100_hw_psf4ad:
/* do nothing */
case sis1100_hw_invalid:
/* do nothing */
break;
}
}
if (command&handlercomm_lemo) {
new_irqs|=sis1100_lemo_handler(sc);
}
if (command&handlercomm_mbx0) {
new_irqs|=sis1100_mbox0_handler(sc);
}
/* this is called from sis1100_link_up_handler for both
'UP' and 'DOWN' of link one second after status change */
if (command&handlercomm_up) {
new_irqs|=sis1100_synch_handler(sc);
}
if (command&handlercomm_ddma) {
new_irqs|=sis1100_ddma_handler(sc);
}
sc->pending_irqs|=new_irqs;
mutex_unlock(&sc->sem_irqinfo);
/* inform processes via signal if requested */
mutex_lock(&sc->sem_fdata);
for (i=0; i<sis1100_MINORUTMASK+1; i++) {
if (sc->fdata[i]) {
struct sis1100_fdata* fd=sc->fdata[i];
if (fd->sig>0 && ((new_irqs & fd->owned_irqs)||
(fd->old_remote_hw!=sc->remote_hw))) {
int res;
/* XXXY muss raus */
pERROR(sc, "irq_pending=%d pending_irqs=0x%x",
irq_pending(sc, fd, fd->owned_irqs),
sc->pending_irqs);
pERROR(sc, "sig=%d new_irqs=0x%x owned_irqs=0x%x",
fd->sig, new_irqs, fd->owned_irqs);
pERROR(sc, "old_remote_hw=%d remote_hw=%d",
fd->old_remote_hw, sc->remote_hw);
/* XXXY muss raus */
pERROR(sc, "send sig to %d", pid_nr(fd->pid));
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
res=kill_proc(fd->pid, fd->sig, 1);
#else
res=kill_pid(fd->pid, fd->sig, 1);
#endif
if (res)
pINFO(sc, "send sig %d to %u: res=%d",
fd->sig, pid_nr(fd->pid), res);
}
}
}
mutex_unlock(&sc->sem_fdata);
/* wake up processes waiting in sis1100_irq_wait or doing select */
#ifdef __NetBSD__
wakeup(&sc->remoteirq_wait);
selwakeup(&sc->sel);
#elif __linux__
wake_up_interruptible(&sc->remoteirq_wait);
//.........这里部分代码省略.........
开发者ID:cjpl,项目名称:mdaq-midas,代码行数:101,代码来源:sis1100_irq_thread.c
示例12: ERR_PTR
//.........这里部分代码省略.........
goto bad_fork_cleanup_audit;
retval = copy_files(clone_flags, p);
if (retval)
goto bad_fork_cleanup_semundo;
retval = copy_fs(clone_flags, p);
if (retval)
goto bad_fork_cleanup_files;
retval = copy_sighand(clone_flags, p);
if (retval)
goto bad_fork_cleanup_fs;
retval = copy_signal(clone_flags, p);
if (retval)
goto bad_fork_cleanup_sighand;
retval = copy_mm(clone_flags, p);
if (retval)
goto bad_fork_cleanup_signal;
retval = copy_namespaces(clone_flags, p);
if (retval)
goto bad_fork_cleanup_mm;
retval = copy_io(clone_flags, p);
if (retval)
goto bad_fork_cleanup_namespaces;
retval = copy_thread(clone_flags, stack_start, stack_size, p, regs);
if (retval)
goto bad_fork_cleanup_io;
if (pid != &init_struct_pid) {
retval = -ENOMEM;
pid = alloc_pid(p->nsproxy->pid_ns);
if (!pid)
goto bad_fork_cleanup_io;
}
p->pid = pid_nr(pid);
p->tgid = p->pid;
if (clone_flags & CLONE_THREAD)
p->tgid = current->tgid;
p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL;
p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr : NULL;
#ifdef CONFIG_BLOCK
p->plug = NULL;
#endif
#ifdef CONFIG_FUTEX
p->robust_list = NULL;
#ifdef CONFIG_COMPAT
p->compat_robust_list = NULL;
#endif
INIT_LIST_HEAD(&p->pi_state_list);
p->pi_state_cache = NULL;
#endif
if ((clone_flags & (CLONE_VM|CLONE_VFORK)) == CLONE_VM)
p->sas_ss_sp = p->sas_ss_size = 0;
user_disable_single_step(p);
clear_tsk_thread_flag(p, TIF_SYSCALL_TRACE);
#ifdef TIF_SYSCALL_EMU
clear_tsk_thread_flag(p, TIF_SYSCALL_EMU);
#endif
clear_all_latency_tracing(p);
if (clone_flags & CLONE_THREAD)
p->exit_signal = -1;
else if (clone_flags & CLONE_PARENT)
p->exit_signal = current->group_leader->exit_signal;
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:67,代码来源:fork.c
示例13: pid_vnr
pid_t pid_vnr(struct pid *pid)
{
return pid_nr(pid);
}
开发者ID:Happy-Ferret,项目名称:net-next-nuse,代码行数:4,代码来源:pid.c
示例14: autofs_fill_super
//.........这里部分代码省略.........
s->s_blocksize_bits = 10;
s->s_magic = AUTOFS_SUPER_MAGIC;
s->s_op = &autofs_sops;
s->s_d_op = &autofs_dentry_operations;
s->s_time_gran = 1;
/*
* Get the root inode and dentry, but defer checking for errors.
*/
ino = autofs_new_ino(sbi);
if (!ino) {
ret = -ENOMEM;
goto fail_free;
}
root_inode = autofs_get_inode(s, S_IFDIR | 0755);
root = d_make_root(root_inode);
if (!root)
goto fail_ino;
pipe = NULL;
root->d_fsdata = ino;
/* Can this call block? */
if (parse_options(data, root_inode, &pgrp, &pgrp_set, sbi)) {
pr_err("called with bogus options\n");
goto fail_dput;
}
/* Test versions first */
if (sbi->max_proto < AUTOFS_MIN_PROTO_VERSION ||
sbi->min_proto > AUTOFS_MAX_PROTO_VERSION) {
pr_err("kernel does not match daemon version "
"daemon (%d, %d) kernel (%d, %d)\n",
sbi->min_proto, sbi->max_proto,
AUTOFS_MIN_PROTO_VERSION, AUTOFS_MAX_PROTO_VERSION);
goto fail_dput;
}
/* Establish highest kernel protocol version */
if (sbi->max_proto > AUTOFS_MAX_PROTO_VERSION)
sbi->version = AUTOFS_MAX_PROTO_VERSION;
else
sbi->version = sbi->max_proto;
sbi->sub_version = AUTOFS_PROTO_SUBVERSION;
if (pgrp_set) {
sbi->oz_pgrp = find_get_pid(pgrp);
if (!sbi->oz_pgrp) {
pr_err("could not find process group %d\n",
pgrp);
goto fail_dput;
}
} else {
sbi->oz_pgrp = get_task_pid(current, PIDTYPE_PGID);
}
if (autofs_type_trigger(sbi->type))
__managed_dentry_set_managed(root);
root_inode->i_fop = &autofs_root_operations;
root_inode->i_op = &autofs_dir_inode_operations;
pr_debug("pipe fd = %d, pgrp = %u\n",
sbi->pipefd, pid_nr(sbi->oz_pgrp));
pipe = fget(sbi->pipefd);
if (!pipe) {
pr_err("could not open pipe file descriptor\n");
goto fail_put_pid;
}
ret = autofs_prepare_pipe(pipe);
if (ret < 0)
goto fail_fput;
sbi->pipe = pipe;
sbi->flags &= ~AUTOFS_SBI_CATATONIC;
/*
* Success! Install the root dentry now to indicate completion.
*/
s->s_root = root;
return 0;
/*
* Failure ... clean up.
*/
fail_fput:
pr_err("pipe file descriptor does not contain proper ops\n");
fput(pipe);
fail_put_pid:
put_pid(sbi->oz_pgrp);
fail_dput:
dput(root);
goto fail_free;
fail_ino:
autofs_free_ino(ino);
fail_free:
kfree(sbi);
s->s_fs_info = NULL;
return ret;
}
开发者ID:multipath-tcp,项目名称:mptcp_net-next,代码行数:101,代码来源:inode.c
示例15: __create_hw_context
static struct i915_gem_context *
__create_hw_context(struct drm_i915_private *dev_priv,
struct drm_i915_file_private *file_priv)
{
struct i915_gem_context *ctx;
int ret;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (ctx == NULL)
return ERR_PTR(-ENOMEM);
ret = assign_hw_id(dev_priv, &ctx->hw_id);
if (ret) {
kfree(ctx);
return ERR_PTR(ret);
}
kref_init(&ctx->ref);
list_add_tail(&ctx->link, &dev_priv->context_list);
ctx->i915 = dev_priv;
if (dev_priv->hw_context_size) {
struct drm_i915_gem_object *obj;
struct i915_vma *vma;
obj = alloc_context_obj(dev_priv, dev_priv->hw_context_size);
if (IS_ERR(obj)) {
ret = PTR_ERR(obj);
goto err_out;
}
vma = i915_vma_instance(obj, &dev_priv->ggtt.base, NULL);
if (IS_ERR(vma)) {
i915_gem_object_put(obj);
ret = PTR_ERR(vma);
goto err_out;
}
ctx->engine[RCS].state = vma;
}
/* Default context will never have a file_priv */
ret = DEFAULT_CONTEXT_HANDLE;
if (file_priv) {
ret = idr_alloc(&file_priv->context_idr, ctx,
DEFAULT_CONTEXT_HANDLE, 0, GFP_KERNEL);
if (ret < 0)
goto err_out;
}
ctx->user_handle = ret;
ctx->file_priv = file_priv;
if (file_priv) {
ctx->pid = get_task_pid(current, PIDTYPE_PID);
ctx->name = kasprintf(GFP_KERNEL, "%s[%d]/%x",
current->comm,
pid_nr(ctx->pid),
ctx->user_handle);
if (!ctx->name) {
ret = -ENOMEM;
goto err_pid;
}
}
/* NB: Mark all slices as needing a remap so that when the context first
* loads it will restore whatever remap state already exists. If there
* is no remap info, it will be a NOP. */
ctx->remap_slice = ALL_L3_SLICES(dev_priv);
i915_gem_context_set_bannable(ctx);
ctx->ring_size = 4 * PAGE_SIZE;
ctx->desc_template =
default_desc_template(dev_priv, dev_priv->mm.aliasing_ppgtt);
/* GuC requires the ring to be placed above GUC_WOPCM_TOP. If GuC is not
* present or not in use we still need a small bias as ring wraparound
* at offset 0 sometimes hangs. No idea why.
*/
if (HAS_GUC(dev_priv) && i915.enable_guc_loading)
ctx->ggtt_offset_bias = GUC_WOPCM_TOP;
else
ctx->ggtt_offset_bias = I915_GTT_PAGE_SIZE;
return ctx;
err_pid:
put_pid(ctx->pid);
idr_remove(&file_priv->context_idr, ctx->user_handle);
err_out:
context_close(ctx);
return ERR_PTR(ret);
}
开发者ID:asmalldev,项目名称:linux,代码行数:92,代码来源:i915_gem_context.c
示例16: ugidctl_setgroups
static long ugidctl_setgroups(struct ugidctl_context *ctx, void __user *arg)
{
struct ugidctl_setgroups_rq req;
enum pid_type ptype;
gid_t __user *list;
struct cred *cred;
unsigned i, count;
gid_t *bulk;
pid_t pid;
long rc;
if (copy_from_user(&req, arg, sizeof(req)))
return -EFAULT;
arg += sizeof(req);
list = arg;
count = (unsigned) req.count;
if (count > NGROUPS_MAX)
return -EINVAL;
if (!count)
return ugidctl_sys_setgroups(0, arg);
if (capable(CAP_SETGID))
return ugidctl_sys_setgroups((int) count, list);
if (memcmp(ctx->key, req.key, sizeof(ctx->key)))
return -EPERM;
mutex_lock(&ctx->lock);
ptype = ctx->ptype;
pid = ctx->pid;
mutex_unlock(&ctx->lock);
if (pid != pid_nr(get_task_pid(current, ptype)))
return -EPERM;
bulk = kmalloc(count > UGIDCTL_BULKSIZE ?
sizeof(gid_t) * UGIDCTL_BULKSIZE :
sizeof(gid_t) * count, GFP_KERNEL);
if (!bulk)
return -ENOMEM;
while (count) {
unsigned size = count > UGIDCTL_BULKSIZE ?
UGIDCTL_BULKSIZE : count;
if (copy_from_user(bulk, arg, sizeof(gid_t) * size))
return -EFAULT;
mutex_lock(&ctx->lock);
for (i = 0; i < size; i++) {
if (ugidctl_find_gid(ctx, bulk[i])) {
mutex_unlock(&ctx->lock);
kfree(bulk);
return -EPERM;
}
}
mutex_unlock(&ctx->lock);
arg += sizeof(gid_t) * size;
count -= size;
}
kfree(bulk);
cred = prepare_creds();
if (!cred)
return -ENOMEM;
cap_raise(cred->cap_effective, CAP_SETGID);
commit_creds(cred);
rc = ugidctl_sys_setgroups((int) req.count, list);
cred = prepare_creds();
if (!cred) {
/* unable to restore process capabilities - kill process */
do_exit(SIGKILL);
return -ENOMEM;
}
cap_lower(cred->cap_effective, CAP_SETGID);
commit_creds(cred);
return rc;
}
开发者ID:004helix,项目名称:ugidctl,代码行数:95,代码来源:ugidctl-dev.c
示例17: ERR_PTR
//.........这里部分代码省略.........
if ((retval = copy_semundo(clone_flags, p)))
goto bad_fork_cleanup_audit;
if ((retval = copy_files(clone_flags, p)))
goto bad_fork_cleanup_semundo;
if ((retval = copy_fs(clone_flags, p)))
goto bad_fork_cleanup_files;
if ((retval = copy_sighand(clone_flags, p)))
goto bad_fork_cleanup_fs;
if ((retval = copy_signal(clone_flags, p)))
goto bad_fork_cleanup_sighand;
if ((retval = copy_mm(clone_flags, p)))
goto bad_fork_cleanup_signal;
if ((retval = copy_namespaces(clone_flags, p)))
goto bad_fork_cleanup_mm;
if ((retval = copy_io(clone_flags, p)))
goto bad_fork_cleanup_namespaces;
retval = copy_thread(clone_flags, stack_start, stack_size, p, regs);
if (retval)
goto bad_fork_cleanup_io;
if (pid != &init_struct_pid) {
retval = -ENOMEM;
pid = alloc_pid(p->nsproxy->pid_ns);
if (!pid)
goto bad_fork_cleanup_io;
if (clone_flags & CLONE_NEWPID) {
retval = pid_ns_prepare_proc(p->nsproxy->pid_ns);
if (retval < 0)
goto bad_fork_free_pid;
}
}
p->pid = pid_nr(pid);
p->tgid = p->pid;
if (clone_flags & CLONE_THREAD)
p->tgid = current->tgid;
if (current->nsproxy != p->nsproxy) {
retval = ns_cgroup_clone(p, pid);
if (retval)
goto bad_fork_free_pid;
}
p->set_child_tid = (clone_flags & CLONE_CHILD_SETTID) ? child_tidptr : NULL;
/*
* Clear TID on mm_release()?
*/
p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr: NULL;
#ifdef CONFIG_FUTEX
p->robust_list = NULL;
#ifdef CONFIG_COMPAT
p->compat_robust_list = NULL;
#endif
INIT_LIST_HEAD(&p->pi_state_list);
p->pi_state_cache = NULL;
#endif
/*
* sigaltstack should be cleared when sharing the same VM
*/
if ((clone_flags & (CLONE_VM|CLONE_VFORK)) == CLONE_VM)
p->sas_ss_sp = p->sas_ss_size = 0;
/*
* Syscall tracing should be turned off in the child regardless
* of CLONE_PTRACE.
开发者ID:genua,项目名称:anoubis_os,代码行数:67,代码来源:fork.c
示例18: ERR_PTR
/*
* This creates a new process as a copy of the old one,
* but does not actually start it yet.
*
* It copies the registers, and all the appropriate
* parts of the process environment (as per the clone
* flags). The actual kick-off is left to the caller.
*/
static struct task_struct *copy_process(unsigned long clone_flags,
unsigned long stack_start,
struct pt_regs *regs,
unsigned long stack_size,
int __user *parent_tidptr,
int __user *child_tidptr,
struct pid *pid)
{
int retval;
struct task_struct *p;
if ((clone_flags & (CLONE_NEWNS|CLONE_FS)) == (CLONE_NEWNS|CLONE_FS))
return ERR_PTR(-EINVAL);
/*
* Thread groups must share signals as well, and detached threads
* can only be started up within the thread group.
*/
if ((clone_flags & CLONE_THREAD) && !(clone_flags & CLONE_SIGHAND))
return ERR_PTR(-EINVAL);
/*
* Shared signal handlers imply shared VM. By way of the above,
* thread groups also imply shared VM. Blocking this case allows
* for various simplifications in other code.
*/
if ((clone_flags & CLONE_SIGHAND) && !(clone_flags & CLONE_VM))
return ERR_PTR(-EINVAL);
retval = security_task_create(clone_flags);
if (retval)
goto fork_out;
retval = -ENOMEM;
p = dup_task_struct(current);
if (!p)
goto fork_out;
rt_mutex_init_task(p);
#ifdef CONFIG_PROVE_LOCKING
DEBUG_LOCKS_WARN_ON(!p->hardirqs_enabled);
DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
#endif
retval = -EAGAIN;
if (atomic_read(&p->user->processes) >=
p->signal->rlim[RLIMIT_NPROC].rlim_cur) {
if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
p->user != &root_user)
goto bad_fork_free;
}
atomic_inc(&p->user->__count);
atomic_inc(&p->user->processes);
get_group_info(p->group_info);
/*
* If multiple threads are within copy_process(), then this check
* triggers too late. This doesn't hurt, the check is only there
* to stop root fork bombs.
*/
if (nr_threads >= max_threads)
goto bad_fork_cleanup_count;
if (!try_module_get(task_thread_info(p)->exec_domain->module))
goto bad_fork_cleanup_count;
if (p->binfmt && !try_module_get(p->binfmt->module))
goto bad_fork_cleanup_put_domain;
p->did_exec = 0;
delayacct_tsk_init(p); /* Must remain after dup_task_struct() */
copy_flags(clone_flags, p);
p->pid = pid_nr(pid);
retval = -EFAULT;
if (clone_flags & CLONE_PARENT_SETTID)
if (put_user(p->pid, parent_tidptr))
goto bad_fork_cleanup_delays_binfmt;
INIT_LIST_HEAD(&p->children);
INIT_LIST_HEAD(&p->sibling);
p->vfork_done = NULL;
spin_lock_init(&p->alloc_lock);
clear_tsk_thread_flag(p, TIF_SIGPENDING);
init_sigpending(&p->pending);
p->utime = cputime_zero;
p->stime = cputime_zero;
p->sched_time = 0;
#ifdef CONFIG_DETECT_SOFTLOCKUP
p->last_switch_count = 0;
//.........这里部分代码省略.........
开发者ID:helicopter3,项目名称:wl500g,代码行数:101,代码来源:fork.c
注:本文中的pid_nr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论