MCPcopy Create free account
hub / github.com/ading2210/linuxpdf / fs_lock

Function fs_lock

tinyemu/fs_disk.c:567–590  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565}
566
567static int fs_lock(FSDevice *fs, FSFile *f, const FSLock *lock)
568{
569 int ret;
570 struct flock fl;
571
572 /* XXX: lock directories too */
573 if (!f->is_opened || f->is_dir)
574 return -P9_EPROTO;
575
576 fl.l_type = lock->type;
577 fl.l_whence = SEEK_SET;
578 fl.l_start = lock->start;
579 fl.l_len = lock->length;
580
581 ret = fcntl(f->u.fd, F_SETLK, &fl);
582 if (ret == 0) {
583 ret = P9_LOCK_SUCCESS;
584 } else if (errno == EAGAIN || errno == EACCES) {
585 ret = P9_LOCK_BLOCKED;
586 } else {
587 ret = -errno_to_p9(errno);
588 }
589 return ret;
590}
591
592static int fs_getlock(FSDevice *fs, FSFile *f, FSLock *lock)
593{

Callers

nothing calls this directly

Calls 1

errno_to_p9Function · 0.85

Tested by

no test coverage detected