Adding file-lock interface to flock(2) to (chibi filesystem).

This commit is contained in:
Alex Shinn 2013-10-01 15:14:17 +09:00
parent 82752174c2
commit 20aa69033c
2 changed files with 15 additions and 0 deletions

View file

@ -29,6 +29,8 @@
open/read open/write open/read-write open/read open/write open/read-write
open/create open/exclusive open/truncate open/create open/exclusive open/truncate
open/append open/non-block open/append open/non-block
file-lock
lock/shared lock/exclusive lock/non-blocking lock/unlock
is-a-tty?) is-a-tty?)
(import (chibi) (chibi string)) (import (chibi) (chibi string))
(include-shared "filesystem") (include-shared "filesystem")

View file

@ -185,6 +185,19 @@
;;> File opening modes. ;;> File opening modes.
;;/ ;;/
;;> Applies the specified locking operation using flock(2) to the port
;;> or file-descriptor.
(define-c errno (file-lock "flock") (port-or-fileno int))
(define-c-const int (lock/shared "LOCK_SH"))
(define-c-const int (lock/exclusive "LOCK_EX"))
(define-c-const int (lock/non-blocking "LOCK_NB"))
(define-c-const int (lock/unlock "LOCK_UN"))
;;> Locking operations.
;;/
;;> Returns \scheme{#t} if the given port of file descriptor ;;> Returns \scheme{#t} if the given port of file descriptor
;;> if backed by a TTY object, and \scheme{#f} otherwise. ;;> if backed by a TTY object, and \scheme{#f} otherwise.