Skip to content

Commit 40094fc

Browse files
committed
openkal-macos: this kernel refuses to commit a stream that is not a file, and says so with its own value
1 parent 44f2fb0 commit 40094fc

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/stream.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,13 @@ int kal_stream_flush(kal_stream s) {
4646
// A stream that cannot be committed --- a terminal, a pipe --- has nothing
4747
// to commit, and reporting that as a failure would oblige every caller to
4848
// distinguish it from a failure to reach a medium.
49+
// This kernel refuses the call outright for anything that is not a file:
50+
// its own code says so before it reaches a medium, and the value it uses is
51+
// the one for an operation the object does not support. Measured on the
52+
// system --- a pipe, which is what a stream is when a program's output is
53+
// read by another program.
4954
if (r == -okm::e_inval || r == -okm::e_notty || r == -okm::e_badf
50-
|| r == -okm::e_opnotsupp) return kal_ok;
55+
|| r == -okm::e_opnotsupp || r == -okm::e_notsup) return kal_ok;
5156
return okm::translate(r);
5257
}
5358

src/sys.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@ enum : int {
158158
e_inval = 22, e_nfile = 23, e_mfile = 24, e_notty = 25, e_fbig = 27,
159159
e_nospc = 28, e_spipe = 29, e_rofs = 30, e_pipe = 32, e_range = 34,
160160
e_nametoolong = 63, e_nosys = 78, e_notempty = 66, e_loop = 62,
161+
// This system has two values for an operation the object does not support,
162+
// and they are different numbers: 45 is the one a call upon a resource of
163+
// the wrong kind returns, and 102 is the one a socket returns.
164+
e_notsup = 45,
161165
e_timedout = 60, e_connreset = 54, e_dquot = 69, e_opnotsupp = 102,
162166
};
163167

@@ -192,7 +196,7 @@ inline int translate(okm_long r) {
192196
case e_nomem: return 4; // no memory
193197
case e_nospc: case e_fbig: case e_dquot: return 5; // no space
194198
case e_acces: case e_perm: case e_rofs: return 6; // permission
195-
case e_nosys: case e_opnotsupp: return 7; // unsupported
199+
case e_nosys: case e_opnotsupp: case e_notsup: return 7; // unsupported
196200
case e_pipe: case e_connreset: return 8; // closed
197201
case e_noent: case e_child: case e_nodev: return 9; // not found
198202
case e_exist: case e_busy: return 10; // exists

0 commit comments

Comments
 (0)