本文整理汇总了C++中copyin函数的典型用法代码示例。如果您正苦于以下问题:C++ copyin函数的具体用法?C++ copyin怎么用?C++ copyin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了copyin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mrsas_passthru
//.........这里部分代码省略.........
continue;
ioctl_data_size = user_ioc->sgl[i].iov_len;
if (bus_dma_tag_create( sc->mrsas_parent_tag, // parent
1, 0, // algnmnt, boundary
BUS_SPACE_MAXADDR_32BIT,// lowaddr
BUS_SPACE_MAXADDR, // highaddr
NULL, NULL, // filter, filterarg
ioctl_data_size, // maxsize
1, // msegments
ioctl_data_size, // maxsegsize
BUS_DMA_ALLOCNOW, // flags
NULL, NULL, // lockfunc, lockarg
&ioctl_data_tag[i])) {
device_printf(sc->mrsas_dev, "Cannot allocate ioctl data tag\n");
return (ENOMEM);
}
if (bus_dmamem_alloc(ioctl_data_tag[i], (void **)&ioctl_data_mem[i],
(BUS_DMA_NOWAIT | BUS_DMA_ZERO), &ioctl_data_dmamap[i])) {
device_printf(sc->mrsas_dev, "Cannot allocate ioctl data mem\n");
return (ENOMEM);
}
if (bus_dmamap_load(ioctl_data_tag[i], ioctl_data_dmamap[i],
ioctl_data_mem[i], ioctl_data_size, mrsas_alloc_cb,
&ioctl_data_phys_addr[i], BUS_DMA_NOWAIT)) {
device_printf(sc->mrsas_dev, "Cannot load ioctl data mem\n");
return (ENOMEM);
}
/* Save the physical address and length */
kern_sge32[i].phys_addr = (u_int32_t)ioctl_data_phys_addr[i];
kern_sge32[i].length = user_ioc->sgl[i].iov_len;
/* Copy in data from user space */
ret = copyin(user_ioc->sgl[i].iov_base, ioctl_data_mem[i],
user_ioc->sgl[i].iov_len);
if (ret) {
device_printf(sc->mrsas_dev, "IOCTL copyin failed!\n");
goto out;
}
}
ioctl_sense_size = user_ioc->sense_len;
if (user_ioc->sense_len) {
if (bus_dma_tag_create( sc->mrsas_parent_tag, // parent
1, 0, // algnmnt, boundary
BUS_SPACE_MAXADDR_32BIT,// lowaddr
BUS_SPACE_MAXADDR, // highaddr
NULL, NULL, // filter, filterarg
ioctl_sense_size, // maxsize
1, // msegments
ioctl_sense_size, // maxsegsize
BUS_DMA_ALLOCNOW, // flags
NULL, NULL, // lockfunc, lockarg
&ioctl_sense_tag)) {
device_printf(sc->mrsas_dev, "Cannot allocate ioctl sense tag\n");
return (ENOMEM);
}
if (bus_dmamem_alloc(ioctl_sense_tag, (void **)&ioctl_sense_mem,
(BUS_DMA_NOWAIT | BUS_DMA_ZERO), &ioctl_sense_dmamap)) {
device_printf(sc->mrsas_dev, "Cannot allocate ioctl data mem\n");
return (ENOMEM);
}
if (bus_dmamap_load(ioctl_sense_tag, ioctl_sense_dmamap,
ioctl_sense_mem, ioctl_sense_size, mrsas_alloc_cb,
&ioctl_sense_phys_addr, BUS_DMA_NOWAIT)) {
device_printf(sc->mrsas_dev, "Cannot load ioctl sense mem\n");
开发者ID:ele7enxxh,项目名称:dtrace-pf,代码行数:67,代码来源:mrsas_ioctl.c
示例2: freebsd32_ioctl_sg
static int
freebsd32_ioctl_sg(struct thread *td,
struct freebsd32_ioctl_args *uap, struct file *fp)
{
struct sg_io_hdr io;
struct sg_io_hdr32 io32;
int error;
if ((error = copyin(uap->data, &io32, sizeof(io32))) != 0)
return (error);
CP(io32, io, interface_id);
CP(io32, io, dxfer_direction);
CP(io32, io, cmd_len);
CP(io32, io, mx_sb_len);
CP(io32, io, iovec_count);
CP(io32, io, dxfer_len);
PTRIN_CP(io32, io, dxferp);
PTRIN_CP(io32, io, cmdp);
PTRIN_CP(io32, io, sbp);
CP(io32, io, timeout);
CP(io32, io, flags);
CP(io32, io, pack_id);
PTRIN_CP(io32, io, usr_ptr);
CP(io32, io, status);
CP(io32, io, masked_status);
CP(io32, io, msg_status);
CP(io32, io, sb_len_wr);
CP(io32, io, host_status);
CP(io32, io, driver_status);
CP(io32, io, resid);
CP(io32, io, duration);
CP(io32, io, info);
if ((error = fo_ioctl(fp, SG_IO, (caddr_t)&io, td->td_ucred, td)) != 0)
return (error);
CP(io, io32, interface_id);
CP(io, io32, dxfer_direction);
CP(io, io32, cmd_len);
CP(io, io32, mx_sb_len);
CP(io, io32, iovec_count);
CP(io, io32, dxfer_len);
PTROUT_CP(io, io32, dxferp);
PTROUT_CP(io, io32, cmdp);
PTROUT_CP(io, io32, sbp);
CP(io, io32, timeout);
CP(io, io32, flags);
CP(io, io32, pack_id);
PTROUT_CP(io, io32, usr_ptr);
CP(io, io32, status);
CP(io, io32, masked_status);
CP(io, io32, msg_status);
CP(io, io32, sb_len_wr);
CP(io, io32, host_status);
CP(io, io32, driver_status);
CP(io, io32, resid);
CP(io, io32, duration);
CP(io, io32, info);
error = copyout(&io32, uap->data, sizeof(io32));
return (error);
}
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:64,代码来源:freebsd32_ioctl.c
示例3: svr4_sys_fcntl
int
svr4_sys_fcntl(struct lwp *l, const struct svr4_sys_fcntl_args *uap, register_t *retval)
{
struct sys_fcntl_args fa;
register_t flags;
struct svr4_flock64 ifl64;
struct svr4_flock ifl;
struct flock fl;
int error;
int cmd;
SCARG(&fa, fd) = SCARG(uap, fd);
SCARG(&fa, arg) = SCARG(uap, arg);
switch (SCARG(uap, cmd)) {
case SVR4_F_DUPFD:
cmd = F_DUPFD;
break;
case SVR4_F_GETFD:
cmd = F_GETFD;
break;
case SVR4_F_SETFD:
cmd = F_SETFD;
break;
case SVR4_F_GETFL:
cmd = F_GETFL;
break;
case SVR4_F_SETFL:
/*
* we must save the O_ASYNC flag, as that is
* handled by ioctl(_, I_SETSIG, _) emulation.
*/
SCARG(&fa, cmd) = F_GETFL;
if ((error = sys_fcntl(l, &fa, &flags)) != 0)
return error;
flags &= O_ASYNC;
flags |= svr4_to_bsd_flags((u_long) SCARG(uap, arg));
cmd = F_SETFL;
SCARG(&fa, arg) = (void *) flags;
break;
case SVR4_F_GETLK:
cmd = F_GETLK;
goto lock32;
case SVR4_F_SETLK:
cmd = F_SETLK;
goto lock32;
case SVR4_F_SETLKW:
cmd = F_SETLKW;
lock32:
error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
if (error)
return error;
svr4_to_bsd_flock(&ifl, &fl);
error = do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
if (cmd != F_GETLK || error != 0)
return error;
bsd_to_svr4_flock(&fl, &ifl);
return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
case SVR4_F_DUP2FD:
{
struct sys_dup2_args du;
SCARG(&du, from) = SCARG(uap, fd);
SCARG(&du, to) = (int)(u_long)SCARG(uap, arg);
error = sys_dup2(l, &du, retval);
if (error)
return error;
*retval = SCARG(&du, to);
return 0;
}
case SVR4_F_FREESP:
error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
if (error)
return error;
svr4_to_bsd_flock(&ifl, &fl);
return fd_truncate(l, SCARG(uap, fd), &fl, retval);
case SVR4_F_GETLK64:
cmd = F_GETLK;
goto lock64;
case SVR4_F_SETLK64:
cmd = F_SETLK;
goto lock64;
case SVR4_F_SETLKW64:
cmd = F_SETLKW;
lock64:
error = copyin(SCARG(uap, arg), &ifl64, sizeof ifl64);
if (error)
return error;
svr4_to_bsd_flock64(&ifl64, &fl);
error = do_fcntl_lock(SCARG(uap, fd), cmd, &fl);
if (cmd != F_GETLK || error != 0)
//.........这里部分代码省略.........
开发者ID:eyberg,项目名称:rumpkernel-netbsd-src,代码行数:101,代码来源:svr4_fcntl.c
示例4: sti_ioctl
int
sti_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct sti_screen *scr = (struct sti_screen *)v;
struct sti_rom *rom = scr->scr_rom;
struct wsdisplay_fbinfo *wdf;
struct wsdisplay_cmap *cmapp;
u_int mode, idx, count;
int i, ret;
ret = 0;
switch (cmd) {
case WSDISPLAYIO_SMODE:
mode = *(u_int *)data;
if (scr->scr_wsmode == WSDISPLAYIO_MODE_EMUL &&
mode == WSDISPLAYIO_MODE_DUMBFB)
ret = sti_init(scr, 0);
else if (scr->scr_wsmode == WSDISPLAYIO_MODE_DUMBFB &&
mode == WSDISPLAYIO_MODE_EMUL)
ret = sti_init(scr, STI_TEXTMODE);
scr->scr_wsmode = mode;
break;
case WSDISPLAYIO_GTYPE:
*(u_int *)data = WSDISPLAY_TYPE_STI;
break;
case WSDISPLAYIO_GINFO:
wdf = (struct wsdisplay_fbinfo *)data;
wdf->height = scr->scr_cfg.scr_height;
wdf->width = scr->scr_cfg.scr_width;
wdf->depth = scr->scr_bpp;
if (rom->scment == NULL)
wdf->cmsize = 0;
else
wdf->cmsize = STI_NCMAP;
break;
case WSDISPLAYIO_LINEBYTES:
*(u_int *)data = scr->scr_cfg.fb_width;
break;
case WSDISPLAYIO_GETCMAP:
if (rom->scment == NULL)
return ENODEV;
cmapp = (struct wsdisplay_cmap *)data;
idx = cmapp->index;
count = cmapp->count;
if (idx >= STI_NCMAP || idx + count > STI_NCMAP)
return EINVAL;
if ((ret = copyout(&scr->scr_rcmap[idx], cmapp->red, count)))
break;
if ((ret = copyout(&scr->scr_gcmap[idx], cmapp->green, count)))
break;
if ((ret = copyout(&scr->scr_bcmap[idx], cmapp->blue, count)))
break;
break;
case WSDISPLAYIO_PUTCMAP:
if (rom->scment == NULL)
return ENODEV;
cmapp = (struct wsdisplay_cmap *)data;
idx = cmapp->index;
count = cmapp->count;
if (idx >= STI_NCMAP || idx + count > STI_NCMAP)
return EINVAL;
if ((ret = copyin(cmapp->red, &scr->scr_rcmap[idx], count)))
break;
if ((ret = copyin(cmapp->green, &scr->scr_gcmap[idx], count)))
break;
if ((ret = copyin(cmapp->blue, &scr->scr_bcmap[idx], count)))
break;
for (i = idx + count - 1; i >= idx; i--)
if ((ret = sti_setcment(scr, i, scr->scr_rcmap[i],
scr->scr_gcmap[i], scr->scr_bcmap[i]))) {
#ifdef STIDEBUG
printf("sti_ioctl: "
"sti_setcment(%d, %u, %u, %u): %d\n", i,
(u_int)scr->scr_rcmap[i],
(u_int)scr->scr_gcmap[i],
(u_int)scr->scr_bcmap[i], ret);
#endif
ret = EINVAL;
break;
}
break;
case WSDISPLAYIO_SVIDEO:
case WSDISPLAYIO_GVIDEO:
break;
default:
return (-1); /* not supported yet */
}
return (ret);
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:97,代码来源:sti.c
示例5: post_syscall
//.........这里部分代码省略.........
tnf_long, errno, (long)error);
repost = 1;
}
#endif /* NPROBE */
/*
* Set state to LWP_USER here so preempt won't give us a kernel
* priority if it occurs after this point. Call CL_TRAPRET() to
* restore the user-level priority.
*
* It is important that no locks (other than spinlocks) be entered
* after this point before returning to user mode (unless lwp_state
* is set back to LWP_SYS).
*
* XXX Sampled times past this point are charged to the user.
*/
lwp->lwp_state = LWP_USER;
if (t->t_trapret) {
t->t_trapret = 0;
thread_lock(t);
CL_TRAPRET(t);
thread_unlock(t);
}
if (CPU->cpu_runrun || t->t_schedflag & TS_ANYWAITQ)
preempt();
prunstop();
lwp->lwp_errno = 0; /* clear error for next time */
/*
* The thread lock must be held in order to clear sysnum and reset
* lwp_ap atomically with respect to other threads in the system that
* may be looking at the args via lwp_ap from get_syscall_args().
*/
thread_lock(t);
t->t_sysnum = 0; /* no longer in a system call */
if (lwp_getdatamodel(lwp) == DATAMODEL_NATIVE) {
#if defined(_LP64)
/*
* In case the args were copied to the lwp, reset the
* pointer so the next syscall will have the right
* lwp_ap pointer.
*/
lwp->lwp_ap = (long *)&rp->r_rdi;
} else {
#endif
lwp->lwp_ap = NULL; /* reset on every syscall entry */
}
thread_unlock(t);
lwp->lwp_argsaved = 0;
/*
* If there was a continuing reason for post-syscall processing,
* set the t_post_sys flag for the next system call.
*/
if (repost)
t->t_post_sys = 1;
/*
* If there is a ustack registered for this lwp, and the stack rlimit
* has been altered, read in the ustack. If the saved stack rlimit
* matches the bounds of the ustack, update the ustack to reflect
* the new rlimit. If the new stack rlimit is RLIM_INFINITY, disable
* stack checking by setting the size to 0.
*/
if (lwp->lwp_ustack != 0 && lwp->lwp_old_stk_ctl != 0) {
rlim64_t new_size;
caddr_t top;
stack_t stk;
struct rlimit64 rl;
mutex_enter(&p->p_lock);
new_size = p->p_stk_ctl;
top = p->p_usrstack;
(void) rctl_rlimit_get(rctlproc_legacy[RLIMIT_STACK], p, &rl);
mutex_exit(&p->p_lock);
if (rl.rlim_cur == RLIM64_INFINITY)
new_size = 0;
if (copyin((stack_t *)lwp->lwp_ustack, &stk,
sizeof (stack_t)) == 0 &&
(stk.ss_size == lwp->lwp_old_stk_ctl ||
stk.ss_size == 0) &&
stk.ss_sp == top - stk.ss_size) {
stk.ss_sp = (void *)((uintptr_t)stk.ss_sp +
stk.ss_size - (uintptr_t)new_size);
stk.ss_size = new_size;
(void) copyout(&stk, (stack_t *)lwp->lwp_ustack,
sizeof (stack_t));
}
lwp->lwp_old_stk_ctl = 0;
}
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:101,代码来源:syscall.c
示例6: setquota
/*
* Set various fields of the dqblk according to the command.
* Q_SETQUOTA - assign an entire dqblk structure.
* Q_SETQLIM - assign a dqblk structure except for the usage.
*/
static int
setquota(int cmd, uid_t uid, struct ufsvfs *ufsvfsp,
caddr_t addr, struct cred *cr)
{
struct dquot *dqp;
struct inode *qip;
struct dquot *xdqp;
struct dqblk newlim;
int error;
int scan_type = SQD_TYPE_NONE;
daddr_t bn;
int contig;
if (secpolicy_fs_quota(cr, ufsvfsp->vfs_vfs) != 0)
return (EPERM);
rw_enter(&ufsvfsp->vfs_dqrwlock, RW_WRITER);
/*
* Quotas are not enabled on this file system so there is
* nothing more to do.
*/
if ((ufsvfsp->vfs_qflags & MQ_ENABLED) == 0) {
rw_exit(&ufsvfsp->vfs_dqrwlock);
return (ESRCH);
}
/*
* At this point, the quota subsystem is quiescent on this file
* system so we can do all the work necessary to modify the quota
* information for this user.
*/
if (copyin(addr, (caddr_t)&newlim, sizeof (struct dqblk)) != 0) {
rw_exit(&ufsvfsp->vfs_dqrwlock);
return (EFAULT);
}
error = getdiskquota(uid, ufsvfsp, 0, &xdqp);
if (error) {
rw_exit(&ufsvfsp->vfs_dqrwlock);
return (error);
}
dqp = xdqp;
/*
* Don't change disk usage on Q_SETQLIM
*/
mutex_enter(&dqp->dq_lock);
if (cmd == Q_SETQLIM) {
newlim.dqb_curblocks = dqp->dq_curblocks;
newlim.dqb_curfiles = dqp->dq_curfiles;
}
if (uid == 0) {
/*
* Timelimits for uid 0 set the relative time
* the other users can be over quota for this file system.
* If it is zero a default is used (see quota.h).
*/
ufsvfsp->vfs_btimelimit =
newlim.dqb_btimelimit? newlim.dqb_btimelimit: DQ_BTIMELIMIT;
ufsvfsp->vfs_ftimelimit =
newlim.dqb_ftimelimit? newlim.dqb_ftimelimit: DQ_FTIMELIMIT;
} else {
if (newlim.dqb_bsoftlimit &&
newlim.dqb_curblocks >= newlim.dqb_bsoftlimit) {
if (dqp->dq_bsoftlimit == 0 ||
dqp->dq_curblocks < dqp->dq_bsoftlimit) {
/* If we're suddenly over the limit(s), */
/* start the timer(s) */
newlim.dqb_btimelimit =
(uint32_t)gethrestime_sec() +
ufsvfsp->vfs_btimelimit;
dqp->dq_flags &= ~DQ_BLKS;
} else {
/* If we're currently over the soft */
/* limit and were previously over the */
/* soft limit then preserve the old */
/* time limit but make sure the DQ_BLKS */
/* flag is set since we must have been */
/* previously warned. */
newlim.dqb_btimelimit = dqp->dq_btimelimit;
dqp->dq_flags |= DQ_BLKS;
}
} else {
/* Either no quota or under quota, clear time limit */
newlim.dqb_btimelimit = 0;
dqp->dq_flags &= ~DQ_BLKS;
}
if (newlim.dqb_fsoftlimit &&
newlim.dqb_curfiles >= newlim.dqb_fsoftlimit) {
if (dqp->dq_fsoftlimit == 0 ||
dqp->dq_curfiles < dqp->dq_fsoftlimit) {
/* If we're suddenly over the limit(s), */
/* start the timer(s) */
newlim.dqb_ftimelimit =
//.........这里部分代码省略.........
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:101,代码来源:quotacalls.c
示例7: signotify
int
signotify(int cmd, siginfo_t *siginfo, signotify_id_t *sn_id)
{
k_siginfo_t info;
signotify_id_t id;
proc_t *p;
proc_t *cp = curproc;
signotifyq_t *snqp;
struct cred *cr;
sigqueue_t *sqp;
sigqhdr_t *sqh;
u_longlong_t sid;
model_t datamodel = get_udatamodel();
if (copyin(sn_id, &id, sizeof (signotify_id_t)))
return (set_errno(EFAULT));
if (id.sn_index >= _SIGNOTIFY_MAX || id.sn_index < 0)
return (set_errno(EINVAL));
switch (cmd) {
case SN_PROC:
/* get snid for the given user address of signotifyid_t */
sid = get_sigid(cp, (caddr_t)sn_id);
if (id.sn_pid > 0) {
mutex_enter(&pidlock);
if ((p = prfind(id.sn_pid)) != NULL) {
mutex_enter(&p->p_lock);
if (p->p_signhdr != NULL) {
snqp = SIGN_PTR(p, id.sn_index);
if (snqp->sn_snid == sid) {
mutex_exit(&p->p_lock);
mutex_exit(&pidlock);
return (set_errno(EBUSY));
}
}
mutex_exit(&p->p_lock);
}
mutex_exit(&pidlock);
}
if (copyin_siginfo(datamodel, siginfo, &info))
return (set_errno(EFAULT));
/* The si_code value must indicate the signal will be queued */
if (!sigwillqueue(info.si_signo, info.si_code))
return (set_errno(EINVAL));
if (cp->p_signhdr == NULL) {
/* Allocate signotify pool first time */
sqh = sigqhdralloc(sizeof (signotifyq_t),
_SIGNOTIFY_MAX);
mutex_enter(&cp->p_lock);
if (cp->p_signhdr == NULL) {
/* hang the pool head on proc */
cp->p_signhdr = sqh;
} else {
/* another lwp allocated the pool, free ours */
sigqhdrfree(sqh);
}
} else {
mutex_enter(&cp->p_lock);
}
sqp = sigqalloc(cp->p_signhdr);
if (sqp == NULL) {
mutex_exit(&cp->p_lock);
return (set_errno(EAGAIN));
}
cr = CRED();
sqp->sq_info = info;
sqp->sq_info.si_pid = cp->p_pid;
sqp->sq_info.si_ctid = PRCTID(cp);
sqp->sq_info.si_zoneid = getzoneid();
sqp->sq_info.si_uid = crgetruid(cr);
/* fill the signotifyq_t fields */
((signotifyq_t *)sqp)->sn_snid = sid;
mutex_exit(&cp->p_lock);
/* complete the signotify_id_t fields */
id.sn_index = (signotifyq_t *)sqp - SIGN_PTR(cp, 0);
id.sn_pid = cp->p_pid;
break;
case SN_CANCEL:
case SN_SEND:
sid = get_sigid(cp, (caddr_t)sn_id);
mutex_enter(&pidlock);
if ((id.sn_pid <= 0) || ((p = prfind(id.sn_pid)) == NULL)) {
mutex_exit(&pidlock);
return (set_errno(EINVAL));
}
mutex_enter(&p->p_lock);
mutex_exit(&pidlock);
//.........这里部分代码省略.........
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:101,代码来源:signotify.c
示例8: uhid_ioctl
static int
uhid_ioctl(struct usb_fifo *fifo, u_long cmd, void *addr,
int fflags)
{
struct uhid_softc *sc = usb_fifo_softc(fifo);
struct usb_gen_descriptor *ugd;
uint32_t size;
int error = 0;
uint8_t id;
switch (cmd) {
case USB_GET_REPORT_DESC:
ugd = addr;
if (sc->sc_repdesc_size > ugd->ugd_maxlen) {
size = ugd->ugd_maxlen;
} else {
size = sc->sc_repdesc_size;
}
ugd->ugd_actlen = size;
if (ugd->ugd_data == NULL)
break; /* descriptor length only */
error = copyout(sc->sc_repdesc_ptr, ugd->ugd_data, size);
break;
case USB_SET_IMMED:
if (!(fflags & FREAD)) {
error = EPERM;
break;
}
if (*(int *)addr) {
/* do a test read */
error = uhid_get_report(sc, UHID_INPUT_REPORT,
sc->sc_iid, NULL, NULL, sc->sc_isize);
if (error) {
break;
}
mtx_lock(&sc->sc_mtx);
sc->sc_flags |= UHID_FLAG_IMMED;
mtx_unlock(&sc->sc_mtx);
} else {
mtx_lock(&sc->sc_mtx);
sc->sc_flags &= ~UHID_FLAG_IMMED;
mtx_unlock(&sc->sc_mtx);
}
break;
case USB_GET_REPORT:
if (!(fflags & FREAD)) {
error = EPERM;
break;
}
ugd = addr;
switch (ugd->ugd_report_type) {
case UHID_INPUT_REPORT:
size = sc->sc_isize;
id = sc->sc_iid;
break;
case UHID_OUTPUT_REPORT:
size = sc->sc_osize;
id = sc->sc_oid;
break;
case UHID_FEATURE_REPORT:
size = sc->sc_fsize;
id = sc->sc_fid;
break;
default:
return (EINVAL);
}
if (id != 0)
copyin(ugd->ugd_data, &id, 1);
error = uhid_get_report(sc, ugd->ugd_report_type, id,
NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size));
break;
case USB_SET_REPORT:
if (!(fflags & FWRITE)) {
error = EPERM;
break;
}
ugd = addr;
switch (ugd->ugd_report_type) {
case UHID_INPUT_REPORT:
size = sc->sc_isize;
id = sc->sc_iid;
break;
case UHID_OUTPUT_REPORT:
size = sc->sc_osize;
id = sc->sc_oid;
break;
case UHID_FEATURE_REPORT:
size = sc->sc_fsize;
id = sc->sc_fid;
break;
default:
return (EINVAL);
}
if (id != 0)
copyin(ugd->ugd_data, &id, 1);
//.........这里部分代码省略.........
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:101,代码来源:uhid.c
示例9: syscall2
//.........这里部分代码省略.........
/*
* Code is first argument, followed by actual args.
*/
code = fuword(params);
params += sizeof(int);
} else if (code == SYS___syscall) {
/*
* Like syscall, but code is a quad, so as to maintain
* quad alignment for the rest of the arguments.
*/
code = fuword(params);
params += sizeof(quad_t);
}
}
code &= p->p_sysent->sv_mask;
if (code >= p->p_sysent->sv_size)
callp = &p->p_sysent->sv_table[0];
else
callp = &p->p_sysent->sv_table[code];
narg = callp->sy_narg & SYF_ARGMASK;
#if 0
if (p->p_sysent->sv_name[0] == 'L')
kprintf("Linux syscall, code = %d\n", code);
#endif
/*
* copyin is MP aware, but the tracing code is not
*/
if (narg && params) {
error = copyin(params, (caddr_t)(&args.nosys.sysmsg + 1),
narg * sizeof(register_t));
if (error) {
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSCALL)) {
MAKEMPSAFE(have_mplock);
ktrsyscall(lp, code, narg,
(void *)(&args.nosys.sysmsg + 1));
}
#endif
goto bad;
}
}
#ifdef KTRACE
if (KTRPOINT(td, KTR_SYSCALL)) {
MAKEMPSAFE(have_mplock);
ktrsyscall(lp, code, narg, (void *)(&args.nosys.sysmsg + 1));
}
#endif
/*
* For traditional syscall code edx is left untouched when 32 bit
* results are returned. Since edx is loaded from fds[1] when the
* system call returns we pre-set it here.
*/
args.sysmsg_fds[0] = 0;
args.sysmsg_fds[1] = frame->tf_edx;
/*
* The syscall might manipulate the trap frame. If it does it
* will probably return EJUSTRETURN.
开发者ID:victoredwardocallaghan,项目名称:DragonFlyBSD,代码行数:67,代码来源:trap.c
示例10: quotactl
/*ARGSUSED*/
int
quotactl(struct vnode *vp, intptr_t arg, int flag, struct cred *cr)
{
struct quotctl quot;
struct ufsvfs *ufsvfsp;
int error = 0;
if ((flag & DATAMODEL_MASK) == DATAMODEL_NATIVE) {
if (copyin((caddr_t)arg, ", sizeof (struct quotctl)))
return (EFAULT);
}
#ifdef _SYSCALL32_IMPL
else {
/* quotctl struct from ILP32 callers */
struct quotctl32 quot32;
if (copyin((caddr_t)arg, "32, sizeof (struct quotctl32)))
return (EFAULT);
quot.op = quot32.op;
quot.uid = quot32.uid;
quot.addr = (caddr_t)(uintptr_t)quot32.addr;
}
#endif /* _SYSCALL32_IMPL */
if (quot.uid < 0)
quot.uid = crgetruid(cr);
if (quot.op == Q_SYNC && vp == NULL) {
ufsvfsp = NULL;
} else if (quot.op != Q_ALLSYNC) {
ufsvfsp = (struct ufsvfs *)(vp->v_vfsp->vfs_data);
}
switch (quot.op) {
case Q_QUOTAON:
rw_enter(&dq_rwlock, RW_WRITER);
if (quotas_initialized == 0) {
qtinit2();
quotas_initialized = 1;
}
rw_exit(&dq_rwlock);
error = opendq(ufsvfsp, vp, cr);
break;
case Q_QUOTAOFF:
error = closedq(ufsvfsp, cr);
if (!error) {
invalidatedq(ufsvfsp);
}
break;
case Q_SETQUOTA:
case Q_SETQLIM:
error = setquota(quot.op, (uid_t)quot.uid, ufsvfsp,
quot.addr, cr);
break;
case Q_GETQUOTA:
error = getquota((uid_t)quot.uid, ufsvfsp, (caddr_t)quot.addr,
cr);
break;
case Q_SYNC:
error = qsync(ufsvfsp);
break;
case Q_ALLSYNC:
(void) qsync(NULL);
break;
default:
error = EINVAL;
break;
}
return (error);
}
开发者ID:MatiasNAmendola,项目名称:AuroraUX-SunOS,代码行数:75,代码来源:quotacalls.c
示例11: tw_osli_fw_passthru
/*
* Function name: tw_osli_fw_passthru
* Description: Builds a fw passthru cmd pkt, and submits it to CL.
*
* Input: sc -- ptr to OSL internal ctlr context
* buf -- ptr to ioctl pkt understood by CL
* Output: None
* Return value: 0 -- success
* non-zero-- failure
*/
TW_INT32
tw_osli_fw_passthru(struct twa_softc *sc, TW_INT8 *buf)
{
struct tw_osli_req_context *req;
struct tw_osli_ioctl_no_data_buf *user_buf =
(struct tw_osli_ioctl_no_data_buf *)buf;
TW_TIME end_time;
TW_UINT32 timeout = 60;
TW_UINT32 data_buf_size_adjusted;
struct tw_cl_req_packet *req_pkt;
struct tw_cl_passthru_req_packet *pt_req;
TW_INT32 error;
tw_osli_dbg_dprintf(5, sc, "ioctl: passthru");
if ((req = tw_osli_get_request(sc)) == NULL)
return(EBUSY);
req->req_handle.osl_req_ctxt = req;
req->orig_req = buf;
req->flags |= TW_OSLI_REQ_FLAGS_PASSTHRU;
req_pkt = &(req->req_pkt);
req_pkt->status = 0;
req_pkt->tw_osl_callback = tw_osl_complete_passthru;
/* Let the Common Layer retry the request on cmd queue full. */
req_pkt->flags |= TW_CL_REQ_RETRY_ON_BUSY;
pt_req = &(req_pkt->gen_req_pkt.pt_req);
/*
* Make sure that the data buffer sent to firmware is a
* 512 byte multiple in size.
*/
data_buf_size_adjusted =
(user_buf->driver_pkt.buffer_length +
(sc->sg_size_factor - 1)) & ~(sc->sg_size_factor - 1);
if ((req->length = data_buf_size_adjusted)) {
if ((req->data = malloc(data_buf_size_adjusted,
TW_OSLI_MALLOC_CLASS, M_WAITOK)) == NULL) {
error = ENOMEM;
tw_osli_printf(sc, "error = %d",
TW_CL_SEVERITY_ERROR_STRING,
TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
0x2016,
"Could not alloc mem for "
"fw_passthru data_buf",
error);
goto fw_passthru_err;
}
/* Copy the payload. */
if ((error = copyin((TW_VOID *)(user_buf->pdata),
req->data,
user_buf->driver_pkt.buffer_length)) != 0) {
tw_osli_printf(sc, "error = %d",
TW_CL_SEVERITY_ERROR_STRING,
TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER,
0x2017,
"Could not copyin fw_passthru data_buf",
error);
goto fw_passthru_err;
}
pt_req->sgl_entries = 1; /* will be updated during mapping */
req->flags |= (TW_OSLI_REQ_FLAGS_DATA_IN |
TW_OSLI_REQ_FLAGS_DATA_OUT);
} else
pt_req->sgl_entries = 0; /* no payload */
pt_req->cmd_pkt = (TW_VOID *)(&(user_buf->cmd_pkt));
pt_req->cmd_pkt_length = sizeof(struct tw_cl_command_packet);
if ((error = tw_osli_map_request(req)))
goto fw_passthru_err;
end_time = tw_osl_get_local_time() + timeout;
while (req->state != TW_OSLI_REQ_STATE_COMPLETE) {
mtx_lock(req->ioctl_wake_timeout_lock);
req->flags |= TW_OSLI_REQ_FLAGS_SLEEPING;
error = mtx_sleep(req, req->ioctl_wake_timeout_lock, 0,
"twa_passthru", timeout*hz);
mtx_unlock(req->ioctl_wake_timeout_lock);
if (!(req->flags & TW_OSLI_REQ_FLAGS_SLEEPING))
error = 0;
req->flags &= ~TW_OSLI_REQ_FLAGS_SLEEPING;
if (! error) {
if (((error = req->error_code)) ||
((error = (req->state !=
TW_OSLI_REQ_STATE_COMPLETE))) ||
//.........这里部分代码省略.........
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:101,代码来源:tw_osl_freebsd.c
示例12: abort2
int
abort2(struct thread *td, struct abort2_args *uap)
{
struct proc *p = td->td_proc;
struct sbuf *sb;
void *uargs[16];
int error, i, sig;
/*
* Do it right now so we can log either proper call of abort2(), or
* note, that invalid argument was passed. 512 is big enough to
* handle 16 arguments' descriptions with additional comments.
*/
sb = sbuf_new(NULL, NULL, 512, SBUF_FIXEDLEN);
sbuf_clear(sb);
sbuf_printf(sb, "%s(pid %d uid %d) aborted: ",
p->p_comm, p->p_pid, td->td_ucred->cr_uid);
/*
* Since we can't return from abort2(), send SIGKILL in cases, where
* abort2() was called improperly
*/
sig = SIGKILL;
/* Prevent from DoSes from user-space. */
if (uap->nargs < 0 || uap->nargs > 16)
goto out;
if (uap->nargs > 0) {
if (uap->args == NULL)
goto out;
error = copyin(uap->args, uargs, uap->nargs * sizeof(void *));
if (error != 0)
goto out;
}
/*
* Limit size of 'reason' string to 128. Will fit even when
* maximal number of arguments was chosen to be logged.
*/
if (uap->why != NULL) {
error = sbuf_copyin(sb, uap->why, 128);
if (error < 0)
goto out;
} else {
sbuf_printf(sb, "(null)");
}
if (uap->nargs > 0) {
sbuf_printf(sb, "(");
for (i = 0;i < uap->nargs; i++)
sbuf_printf(sb, "%s%p", i == 0 ? "" : ", ", uargs[i]);
sbuf_printf(sb, ")");
}
/*
* Final stage: arguments were proper, string has been
* successfully copied from userspace, and copying pointers
* from user-space succeed.
*/
sig = SIGABRT;
out:
if (sig == SIGKILL) {
sbuf_trim(sb);
sbuf_printf(sb, " (Reason text inaccessible)");
}
sbuf_cat(sb, "\n");
sbuf_finish(sb);
log(LOG_INFO, "%s", sbuf_data(sb));
sbuf_delete(sb);
exit1(td, W_EXITCODE(0, sig));
return (0);
}
开发者ID:DangerDexter,项目名称:FreeBSD-8.0-dyntick,代码行数:67,代码来源:kern_exit.c
示例13: pci_ioctl
//.........这里部分代码省略.........
/*
* pat_buf_len needs to be:
* num_patterns * sizeof(struct pci_match_conf)
* While it is certainly possible the user just
* allocated a large buffer, but set the number of
* matches correctly, it is far more likely that
* their kernel doesn't match the userland utility
* they're using. It's also possible that the user
* forgot to initialize some variables. Yes, this
* may be overly picky, but I hazard to guess that
* it's far more likely to just catch folks that
* updated their kernel but not their userland.
*/
#ifdef PRE7_COMPAT
if (ap->a_cmd == PCIOCGETCONF_OLD)
pbufsz = sizeof(struct pci_match_conf_old);
else
#endif
pbufsz = sizeof(struct pci_match_conf);
if (cio->num_patterns * pbufsz != cio->pat_buf_len) {
/* The user made a mistake, return an error. */
cio->status = PCI_GETCONF_ERROR;
error = EINVAL;
break;
}
/*
* Allocate a buffer to hold the patterns.
*/
#ifdef PRE7_COMPAT
if (ap->a_cmd == PCIOCGETCONF_OLD) {
pattern_buf_old = kmalloc(cio->pat_buf_len,
M_TEMP, M_WAITOK);
error = copyin(cio->patterns,
pattern_buf_old, cio->pat_buf_len);
} else
#endif
{
pattern_buf = kmalloc(cio->pat_buf_len, M_TEMP,
M_WAITOK);
error = copyin(cio->patterns, pattern_buf,
cio->pat_buf_len);
}
if (error != 0) {
error = EINVAL;
goto getconfexit;
}
num_patterns = cio->num_patterns;
} else if ((cio->num_patterns > 0)
|| (cio->pat_buf_len > 0)) {
/*
* The user made a mistake, spit out an error.
*/
cio->status = PCI_GETCONF_ERROR;
error = EINVAL;
break;
}
/*
* Go through the list of devices and copy out the devices
* that match the user's criteria.
*/
for (cio->num_matches = 0, error = 0, i = 0,
dinfo = STAILQ_FIRST(devlist_head);
(dinfo != NULL) && (cio->num_matches < ionum)
&& (error == 0) && (i < pci_numdevs) && (dinfo != NULL);
开发者ID:vishesh,项目名称:DragonFlyBSD,代码行数:67,代码来源:pci_user.c
示例14: ext2_mount
/*
* VFS Operations.
*
* mount system call
*
* Parameters:
* data: this is actually a (struct ext2_args *)
*/
static int
ext2_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
{
struct vnode *devvp;
struct ext2_args args;
struct ext2mount *ump = NULL;
struct ext2_sb_info *fs;
size_t size;
int error, flags;
mode_t accessmode;
struct nlookupdata nd;
if ((error = copyin(data, (caddr_t)&args, sizeof (struct ext2_args))) != 0)
return (error);
/*
* If updating, check whether changing from read-only to
* read/write; if there is no device name, that's all we do.
*/
if (mp->mnt_flag & MNT_UPDATE) {
ump = VFSTOEXT2(mp);
fs = ump->um_e2fs;
devvp = ump->um_devvp;
error = 0;
if (fs->s_rd_only == 0 && (mp->mnt_flag & MNT_RDONLY)) {
flags = WRITECLOSE;
if (mp->mnt_flag & MNT_FORCE)
flags |= FORCECLOSE;
if (vfs_busy(mp, LK_NOWAIT))
return (EBUSY);
error = ext2_flushfiles(mp, flags);
vfs_unbusy(mp);
if (!error && fs->s_wasvalid) {
fs->s_es->s_state |= EXT2_VALID_FS;
ext2_sbupdate(ump, MNT_WAIT);
}
fs->s_rd_only = 1;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
VOP_OPEN(devvp, FREAD, FSCRED, NULL);
VOP_CLOSE(devvp, FREAD|FWRITE, NULL);
vn_unlock(devvp);
}
if (!error && (mp->mnt_flag & MNT_RELOAD))
error = ext2_reload(mp, cred);
if (error)
return (error);
if (ext2_check_sb_compat(fs->s_es, devvp->v_rdev,
(mp->mnt_kern_flag & MNTK_WANTRDWR) == 0) != 0)
return (EPERM);
if (fs->s_rd_only && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
/*
* If upgrade to read-write by non-root, then verify
* that user has necessary permissions on the device.
*/
if (cred->cr_uid != 0) {
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
error = VOP_EACCESS(devvp, VREAD | VWRITE, cred);
if (error) {
vn_unlock(devvp);
return (error);
}
vn_unlock(devvp);
}
if ((fs->s_es->s_state & EXT2_VALID_FS) == 0 ||
(fs->s_es->s_state & EXT2_ERROR_FS)) {
if (mp->mnt_flag & MNT_FORCE) {
kprintf(
"WARNING: %s was not properly dismounted\n",
fs->fs_fsmnt);
} else {
kprintf(
"WARNING: R/W mount of %s denied. Filesystem is not clean - run fsck\n",
fs->fs_fsmnt);
return (EPERM);
}
}
fs->s_es->s_state &= ~EXT2_VALID_FS;
ext2_sbupdate(ump, MNT_WAIT);
fs->s_rd_only = 0;
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
VOP_OPEN(devvp, FREAD|FWRITE, FSCRED, NULL);
VOP_CLOSE(devvp, FREAD, NULL);
vn_unlock(devvp);
}
if (args.fspec == NULL) {
/*
* Process export requests.
*/
return (vfs_export(mp, &ump->um_export, &args.export));
}
}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:100,代码来源:ext2_vfsops.c
示例15: freebsd32_ioctl_pciocgetconf
static int
freebsd32_ioctl_pciocgetconf(struct thread *td,
struct freebsd32_ioctl_args *uap, struct file *fp)
{
struct pci_conf_io pci;
struct pci_conf_io32 pci32;
struct pci_match_conf32 pmc32;
struct pci_match_conf32 *pmc32p;
struct pci_match_conf pmc;
struct pci_match_conf *pmcp;
struct pci_conf32 pc32;
struct pci_conf32 *pc32p;
struct pci_conf pc;
struct pci_conf *pcp;
u_int32_t i;
u_int32_t npat_to_convert;
u_int32_t nmatch_to_convert;
vm_offset_t addr;
int error;
if ((error = copyin(uap->data, &pci32, sizeof(pci32))) != 0)
return (error);
CP(pci32, pci, num_patterns);
CP(pci32, pci, offset);
CP(pci32, pci, generation);
npat_to_convert = pci32.pat_buf_len / sizeof(struct pci_match_conf32);
pci.pat_buf_len = npat_to_convert * sizeof(struct pci_match_conf);
pci.patterns = NULL;
nmatch_to_convert = pci32.match_buf_len / sizeof(struct pci_conf32);
pci.match_buf_len = nmatch_to_convert * sizeof(struct pci_conf);
pci.matches = NULL;
if ((error = copyout_map(td, &addr, pci.pat_buf_len)) != 0)
goto cleanup;
pci.patterns = (struct pci_match_conf *)addr;
if ((error = copyout_map(td, &addr, pci.match_buf_len)) != 0)
goto cleanup;
pci.matches = (struct pci_conf *)addr;
npat_to_convert = min(npat_to_convert, pci.num_patterns);
for (i = 0, pmc32p = (struct pci_match_conf32 *)PTRIN(pci32.patterns),
pmcp = pci.patterns;
i < npat_to_convert; i++, pmc32p++, pmcp++) {
if ((error = copyin(pmc32p, &pmc32, sizeof(pmc32))) != 0)
goto cleanup;
CP(pmc32,pmc,pc_sel);
strlcpy(pmc.pd_name, pmc32.pd_name, sizeof(pmc.pd_name));
CP(pmc32,pmc,pd_unit);
CP(pmc32,pmc,pc_vendor);
CP(pmc32,pmc,pc_device);
CP(pmc32,pmc,pc_class);
CP(pmc32,pmc,flags);
if ((error = copyout(&pmc, pmcp, sizeof(pmc))) != 0)
goto cleanup;
}
if ((error = fo_ioctl(fp, PCIOCGETCONF, (caddr_t)&pci,
td->td_ucred, td)) != 0)
goto cleanup;
nmatch_to_convert = min(nmatch_to_convert, pci.num_matches);
for (i = 0, pcp = pci.matches,
pc32p = (struct pci_conf32 *)PTRIN(pci32.matches);
i < nmatch_to_convert; i++, pcp++, pc32p++) {
if ((error = copyin(pcp, &pc, sizeof(pc))) != 0)
goto cleanup;
CP(pc,pc32,pc_sel);
CP(pc,pc32,pc_hdr);
CP(pc,pc32,pc_subvendor);
CP(pc,pc32,pc_subdevice);
CP(pc,pc32,pc_vendor);
CP(pc,pc32,pc_device);
CP(pc,pc32,pc_class);
CP(pc,pc32,pc_subclass);
CP(pc,pc32,pc_progif);
CP(pc,pc32,pc_revid);
strlcpy(pc32.pd_name, pc.pd_name, sizeof(pc32.pd_name));
CP(pc,pc32,pd_unit);
if ((error = copyout(&pc32, pc32p, sizeof(pc32))) != 0)
goto cleanup;
}
CP(pci, pci32, num_matches);
CP(pci, pci32, offset);
CP(pci, pci32, generation);
CP(pci, pci32, status);
error = copyout(&pci32, uap->data, sizeof(pci32));
cleanup:
if (pci.patterns)
copyout_unmap(td, (vm_offset_t)pci.patterns, pci.pat_buf_len);
if (pci.matches)
copyout_unmap(td, (vm_offset_t)pci.matches, pci.match_buf_len);
return (error);
//.........这里部分代码省略.........
开发者ID:jaredmcneill,项目名称:freebsd,代码行数:101,代码来源:freebsd32_ioctl.c
示例16: ncp_conn_handler
static int
ncp_conn_handler(struct proc *p, struct sncp_request_args *uap,
struct ncp_conn *conn, struct ncp_handle *hp)
{
int error=0, rqsize, subfn;
struct ucred *cred;
char *pdata;
cred = p->p_ucred;
error = copyin(&uap->ncpbuf->rqsize, &rqsize, sizeof(int));
if (error) return(error);
error = 0;
pdata = uap->ncpbuf->packet;
subfn = *(pdata++) & 0xff;
rqsize--;
switch (subfn) {
case NCP_CONN_READ: case NCP_CONN_WRITE: {
struct ncp_rw rwrq;
struct uio auio;
struct iovec iov;
if (rqsize != sizeof(rwrq)) return (EBADRPC);
error = copyin(pdata,&rwrq,rqsize);
if (error) return (error);
iov.iov_base = rwrq.nrw_base;
iov.iov_len = rwrq.nrw_cnt;
auio.uio_iov = &iov;
auio.uio_iovcnt = 1;
auio.uio_offset = rwrq.nrw_offset;
auio.uio_resid = rwrq.nrw_cnt;
auio.uio_segflg = UIO_USERSPACE;
auio.uio_rw = (subfn == NCP_CONN_READ) ? UIO_READ : UIO_WRITE;
auio.uio_procp = p;
error = ncp_conn_lock(conn,p,cred,NCPM_EXECUTE);
if (error) return(error);
if (subfn == NCP_CONN_READ)
error = ncp_read(conn, &rwrq.nrw_fh, &auio, cred);
else
error = ncp_write(conn, &rwrq.nrw_fh, &auio, cred);
rwrq.nrw_cnt -= auio.uio_resid;
ncp_conn_unlock(conn,p);
p->p_retval[0] = rwrq.nrw_cnt;
break;
} /* case int_read/write */
case NCP_CONN_SETFLAGS: {
u_int16_t mask, flags;
error = copyin(pdata,&mask, sizeof(mask));
if (error) return error;
pdata += sizeof(mask);
error = copyin(pdata,&flags,sizeof(flags));
if (error) return error;
error = ncp_conn_lock(conn,p,cred,NCPM_WRITE);
if (error) return error;
if (mask & NCPFL_PERMANENT) {
conn->flags &= ~NCPFL_PERMANENT;
conn->flags |= (flags & NCPFL_PERMANENT);
}
if (mask & NCPFL_PRIMARY) {
error = ncp_conn_setprimary(conn, flags & NCPFL_PRIMARY);
if (error) {
ncp_conn_unlock(conn,p);
break;
}
}
ncp_conn_unlock(conn,p);
break;
}
case NCP_CONN_LOGIN: {
struct ncp_conn_login la;
if (rqsize != sizeof(la)) return (EBADRPC);
if ((error = copyin(pdata,&la,rqsize)) != 0) break;
error = ncp_conn_lock(conn, p, cred, NCPM_EXECUTE | NCPM_WRITE);
if (error) return error;
error = ncp_login(conn, la.username, la.objtype, la.password, p, p->p_ucred);
ncp_conn_unlock(conn, p);
p->p_retval[0] = error;
break;
}
case NCP_CONN_GETINFO: {
struct ncp_conn_stat ncs;
int len = sizeof(ncs);
error = ncp_conn_lock(conn, p, p->p_ucred, NCPM_READ);
if (error) return error;
ncp_conn_getinfo(conn, &ncs);
copyout(&len, &uap->ncpbuf->rpsize, sizeof(int));
error = copyout(&ncs, &uap->ncpbuf->packet, len);
ncp_conn_unlock(conn, p);
break;
}
case NCP_CONN_GETUSER: {
int len;
error = ncp_conn_lock(conn, p, p->p_ucred, NCPM_READ);
if (error) return error;
len = (conn->li.user) ? strlen(conn->li.user) + 1 : 0;
copyout(&len, &uap->ncpbuf->rpsize, sizeof(int));
//.........这里部分代码省略.........
开发者ID:UnitedMarsupials,项目名称:kame,代码行数:101,代码来源:ncp_mod.c
示例17: freebsd32_ioctl_md
static int
freebsd32_ioctl_md(struct thread *td, struct freebsd32_ioctl_args *uap,
struct file *fp)
{
struct md_ioctl mdv;
struct md_ioctl32 md32;
u_long com = 0;
int i, error;
if (uap->com & IOC_IN) {
if ((error = copyin(uap->data, &md32, sizeof(md32)))) {
return (error)
|
请发表评论