/usr/lib/s9fes/mode-to-string.scm is in scheme9 2010.11.13-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | ; Scheme 9 from Empty Space, Function Library
; By Nils M Holm, 2010
; See the LICENSE file of the S9fES package for terms of use
;
; (mode->string integer) ==> string
;
; Return a symbolic representation of the access mode specified in
; INTEGER. The resulting string is in the same format as used by
; the ls(1) Unix command.
;
; Example: (mode->string #o5751) ==> "rwsr-x--t"
(require-extension sys-unix)
(load-from-library "bitops.scm")
(define (mode->string mode)
(letrec
((bit*?
(lambda (a b)
(not (zero? (bit* a b)))))
(flag
(lambda (f y n)
(if (bit*? mode f)
y
n))))
(string-append (flag sys:s-irusr "r" "-")
(flag sys:s-iwusr "w" "-")
(if (bit*? mode sys:s-isuid)
(flag sys:s-ixusr "s" "S")
(flag sys:s-ixusr "x" "-"))
(flag sys:s-irgrp "r" "-")
(flag sys:s-iwgrp "w" "-")
(if (bit*? mode sys:s-isgid)
(flag sys:s-ixgrp "s" "S")
(flag sys:s-ixgrp "x" "-"))
(flag sys:s-iroth "r" "-")
(flag sys:s-iwoth "w" "-")
(if (bit*? mode sys:s-isvtx)
(flag sys:s-ixoth "t" "T")
(flag sys:s-ixoth "x" "-")))))
|