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

Function lf_advlockasync

freebsd/kern/kern_lockf.c:416–744  ·  view source on GitHub ↗

* Advisory record locking support */

Source from the content-addressed store, hash-verified

414 * Advisory record locking support
415 */
416int
417lf_advlockasync(struct vop_advlockasync_args *ap, struct lockf **statep,
418 u_quad_t size)
419{
420 struct lockf *state;
421 struct flock *fl = ap->a_fl;
422 struct lockf_entry *lock;
423 struct vnode *vp = ap->a_vp;
424 caddr_t id = ap->a_id;
425 int flags = ap->a_flags;
426 int hash;
427 struct lock_owner *lo;
428 off_t start, end, oadd;
429 int error;
430
431 /*
432 * Handle the F_UNLKSYS case first - no need to mess about
433 * creating a lock owner for this one.
434 */
435 if (ap->a_op == F_UNLCKSYS) {
436 lf_clearremotesys(fl->l_sysid);
437 return (0);
438 }
439
440 /*
441 * Convert the flock structure into a start and end.
442 */
443 switch (fl->l_whence) {
444 case SEEK_SET:
445 case SEEK_CUR:
446 /*
447 * Caller is responsible for adding any necessary offset
448 * when SEEK_CUR is used.
449 */
450 start = fl->l_start;
451 break;
452
453 case SEEK_END:
454 if (size > OFF_MAX ||
455 (fl->l_start > 0 && size > OFF_MAX - fl->l_start))
456 return (EOVERFLOW);
457 start = size + fl->l_start;
458 break;
459
460 default:
461 return (EINVAL);
462 }
463 if (start < 0)
464 return (EINVAL);
465 if (fl->l_len < 0) {
466 if (start == 0)
467 return (EINVAL);
468 end = start - 1;
469 start += fl->l_len;
470 if (start < 0)
471 return (EINVAL);
472 } else if (fl->l_len == 0) {
473 end = OFF_MAX;

Callers 2

vop_stdadvlockasyncFunction · 0.85
lf_advlockFunction · 0.85

Calls 15

lf_clearremotesysFunction · 0.85
lf_hash_ownerFunction · 0.85
lf_owner_matchesFunction · 0.85
mallocFunction · 0.85
lf_print_ownerFunction · 0.85
lf_alloc_lockFunction · 0.85
lf_free_lockFunction · 0.85
lf_setlockFunction · 0.85
lf_clearlockFunction · 0.85
lf_getlockFunction · 0.85
lf_cancelFunction · 0.85
lf_blocksFunction · 0.85

Tested by

no test coverage detected