MCPcopy Create free account
hub / github.com/F-Stack/f-stack / kern_fcntl

Function kern_fcntl

freebsd/kern/kern_descrip.c:471–858  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471int
472kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
473{
474 struct filedesc *fdp;
475 struct flock *flp;
476 struct file *fp, *fp2;
477 struct filedescent *fde;
478 struct proc *p;
479 struct vnode *vp;
480 struct mount *mp;
481 int error, flg, seals, tmp;
482 uint64_t bsize;
483 off_t foffset;
484
485 error = 0;
486 flg = F_POSIX;
487 p = td->td_proc;
488 fdp = p->p_fd;
489
490 AUDIT_ARG_FD(cmd);
491 AUDIT_ARG_CMD(cmd);
492 switch (cmd) {
493 case F_DUPFD:
494 tmp = arg;
495 error = kern_dup(td, FDDUP_FCNTL, 0, fd, tmp);
496 break;
497
498 case F_DUPFD_CLOEXEC:
499 tmp = arg;
500 error = kern_dup(td, FDDUP_FCNTL, FDDUP_FLAG_CLOEXEC, fd, tmp);
501 break;
502
503 case F_DUP2FD:
504 tmp = arg;
505 error = kern_dup(td, FDDUP_FIXED, 0, fd, tmp);
506 break;
507
508 case F_DUP2FD_CLOEXEC:
509 tmp = arg;
510 error = kern_dup(td, FDDUP_FIXED, FDDUP_FLAG_CLOEXEC, fd, tmp);
511 break;
512
513 case F_GETFD:
514 error = EBADF;
515 FILEDESC_SLOCK(fdp);
516 fde = fdeget_locked(fdp, fd);
517 if (fde != NULL) {
518 td->td_retval[0] =
519 (fde->fde_flags & UF_EXCLOSE) ? FD_CLOEXEC : 0;
520 error = 0;
521 }
522 FILEDESC_SUNLOCK(fdp);
523 break;
524
525 case F_SETFD:
526 error = EBADF;
527 FILEDESC_XLOCK(fdp);
528 fde = fdeget_locked(fdp, fd);

Callers 2

kern_fcntl_freebsdFunction · 0.85
ff_fcntlFunction · 0.85

Calls 10

kern_dupFunction · 0.85
fdeget_lockedFunction · 0.85
fget_fcntlFunction · 0.85
fo_ioctlFunction · 0.85
fget_unlockedFunction · 0.85
foffset_getFunction · 0.85
fo_add_sealsFunction · 0.85
fo_get_sealsFunction · 0.85
vn_lockFunction · 0.85
priv_checkFunction · 0.70

Tested by

no test coverage detected