Debian Codegraph @

os/+dragonfly/fcntl.ha

raw
1 // SPDX-License-Identifier: MPL-2.0
2 // (c) Hare authors <https://harelang.org>
3
4 use errors;
5 use fs;
6 use io;
7 use rt;
8
9 // Returns the [[fs::flag]]s associated with a file descriptor. See fcntl(2).
10 export fn getfl(file: io::file) (fs::flag | errors::error) = {
11 match (rt::fcntl(file, rt::F_GETFL, void)) {
12 case let i: int =>
13 return bsd_to_fsflags(i);
14 case let err: rt::errno =>
15 return errors::errno(err);
16 };
17 };
18
19 // Sets the [[fs::flag]]s associated with a file descriptor. Changes to the
20 // access mode (e.g. [[fs::flag::RDWR]] and file creation flags (e.g.
21 // [[fs::flag::CREATE]]) are ignored. See fcntl(2).
22 export fn setfl(file: io::file, flags: fs::flag) (void | errors::error) = {
23 const flags = fsflags_to_bsd(flags)?;
24 match (rt::fcntl(file, rt::F_SETFL, flags)) {
25 case int =>
26 return;
27 case let err: rt::errno =>
28 return errors::errno(err);
29 };
30 };