47 |
#define TTYDEFCHARS |
#define TTYDEFCHARS |
48 |
#include <sys/ttydefaults.h> |
#include <sys/ttydefaults.h> |
49 |
|
|
50 |
/* Count of active opens */ |
/* Count of active opens. */ |
51 |
int nperopens; |
int nperopens; |
52 |
|
|
53 |
/* io_async requests */ |
/* io_async requests. */ |
54 |
struct async_req |
struct async_req |
55 |
{ |
{ |
56 |
mach_port_t notify; |
mach_port_t notify; |
74 |
|
|
75 |
static error_t carrier_error; |
static error_t carrier_error; |
76 |
|
|
77 |
/* Attach this on the hook of any protid that is a ctty. */ |
/* Attach this on the hook of any protid that is a ctty. */ |
78 |
struct protid_hook |
struct protid_hook |
79 |
{ |
{ |
80 |
int refcnt; |
int refcnt; |
318 |
void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *) |
void (*trivfs_peropen_destroy_hook) (struct trivfs_peropen *) |
319 |
= po_destroy_hook; |
= po_destroy_hook; |
320 |
|
|
321 |
/* Tell if CRED can do foreground terminal operations */ |
/* Tell if CRED can do foreground terminal operations. */ |
322 |
static inline int |
static inline int |
323 |
fg_p (struct trivfs_protid *cred) |
fg_p (struct trivfs_protid *cred) |
324 |
{ |
{ |
347 |
st->st_gid = term_group; |
st->st_gid = term_group; |
348 |
} |
} |
349 |
|
|
350 |
/* Implement term_getctty as described in <hurd/term.defs>. */ |
/* Implement term_getctty as described in <hurd/term.defs>. */ |
351 |
kern_return_t |
kern_return_t |
352 |
S_term_getctty (mach_port_t arg, |
S_term_getctty (mach_port_t arg, |
353 |
mach_port_t *id, |
mach_port_t *id, |
375 |
return err; |
return err; |
376 |
} |
} |
377 |
|
|
378 |
/* Implement termctty_open_terminal as described in <hurd/term.defs>. */ |
/* Implement termctty_open_terminal as described in <hurd/term.defs>. */ |
379 |
kern_return_t |
kern_return_t |
380 |
S_termctty_open_terminal (mach_port_t arg, |
S_termctty_open_terminal (mach_port_t arg, |
381 |
int flags, |
int flags, |
412 |
return err; |
return err; |
413 |
} |
} |
414 |
|
|
415 |
/* Implement term_become_ctty as described in <hurd/term.defs>. */ |
/* Implement term_become_ctty as described in <hurd/term.defs>. */ |
416 |
kern_return_t |
kern_return_t |
417 |
S_term_open_ctty (mach_port_t arg, |
S_term_open_ctty (mach_port_t arg, |
418 |
pid_t pid, |
pid_t pid, |
448 |
hook->refcnt = 1; |
hook->refcnt = 1; |
449 |
|
|
450 |
if (newcred->hook) |
if (newcred->hook) |
451 |
/* We inherited CRED's hook, get rid of our ref to it. */ |
/* We inherited CRED's hook, get rid of our ref to it. */ |
452 |
pi_destroy_hook (newcred); |
pi_destroy_hook (newcred); |
453 |
newcred->hook = hook; |
newcred->hook = hook; |
454 |
|
|
465 |
} |
} |
466 |
|
|
467 |
/* Implement chown locally; don't pass the value down to the |
/* Implement chown locally; don't pass the value down to the |
468 |
underlying node. */ |
underlying node. */ |
469 |
error_t |
error_t |
470 |
trivfs_S_file_chown (struct trivfs_protid *cred, |
trivfs_S_file_chown (struct trivfs_protid *cred, |
471 |
mach_port_t reply, |
mach_port_t reply, |
511 |
return err; |
return err; |
512 |
} |
} |
513 |
|
|
514 |
/* Implement chmod locally */ |
/* Implement chmod locally. */ |
515 |
error_t |
error_t |
516 |
trivfs_S_file_chmod (struct trivfs_protid *cred, |
trivfs_S_file_chmod (struct trivfs_protid *cred, |
517 |
mach_port_t reply, |
mach_port_t reply, |
553 |
} |
} |
554 |
|
|
555 |
|
|
556 |
/* Called for user writes to the terminal as described |
/* Called for user writes to the terminal as described in |
557 |
in <hurd/io.defs>. */ |
<hurd/io.defs>. */ |
558 |
error_t |
error_t |
559 |
trivfs_S_io_write (struct trivfs_protid *cred, |
trivfs_S_io_write (struct trivfs_protid *cred, |
560 |
mach_port_t reply, |
mach_port_t reply, |
631 |
return ((cancel && datalen && !*amt) ? (err ?: EINTR) : 0); |
return ((cancel && datalen && !*amt) ? (err ?: EINTR) : 0); |
632 |
} |
} |
633 |
|
|
634 |
/* Called for user reads from the terminal. */ |
/* Called for user reads from the terminal. */ |
635 |
error_t |
error_t |
636 |
trivfs_S_io_read (struct trivfs_protid *cred, |
trivfs_S_io_read (struct trivfs_protid *cred, |
637 |
mach_port_t reply, |
mach_port_t reply, |
749 |
{ |
{ |
750 |
/* The CANCEL flag is being used here to tell the return |
/* The CANCEL flag is being used here to tell the return |
751 |
below to make sure we don't signal EOF on a VDUSP that |
below to make sure we don't signal EOF on a VDUSP that |
752 |
happens at the front of a line. */ |
happens at the front of a line. */ |
753 |
send_signal (SIGTSTP); |
send_signal (SIGTSTP); |
754 |
cancel = 1; |
cancel = 1; |
755 |
break; |
break; |
762 |
|
|
763 |
*datalen = cp - *data; |
*datalen = cp - *data; |
764 |
|
|
765 |
/* If we really read something, set atime */ |
/* If we really read something, set atime. */ |
766 |
if (*datalen || !cancel) |
if (*datalen || !cancel) |
767 |
trivfs_set_atime (termctl); |
trivfs_set_atime (termctl); |
768 |
|
|
1036 |
|
|
1037 |
if (flags & O_READ) |
if (flags & O_READ) |
1038 |
{ |
{ |
1039 |
err = (*bottom->notice_input_flushed) (); |
(*bottom->notice_input_flushed) (); |
1040 |
if (!err) |
clear_queue (inputq); |
|
clear_queue (inputq); |
|
1041 |
} |
} |
1042 |
|
|
1043 |
if (!err && (flags & O_WRITE)) |
if (!err && (flags & O_WRITE)) |
1093 |
{ |
{ |
1094 |
struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0); |
struct trivfs_protid *cred = ports_lookup_port (term_bucket, port, 0); |
1095 |
error_t err; |
error_t err; |
|
int oldlflag; |
|
1096 |
struct termios state; |
struct termios state; |
1097 |
|
|
1098 |
if (!cred) |
if (!cred) |
1108 |
mutex_lock (&global_lock); |
mutex_lock (&global_lock); |
1109 |
|
|
1110 |
if (!(cred->po->openmodes & (O_READ|O_WRITE))) |
if (!(cred->po->openmodes & (O_READ|O_WRITE))) |
1111 |
err = EBADF; |
err = EBADF; |
1112 |
else if (!fg_p (cred)) |
else if (!fg_p (cred)) |
1113 |
err = EBACKGROUND; |
err = EBACKGROUND; |
1114 |
else |
else |
1130 |
|
|
1131 |
if (flushi) |
if (flushi) |
1132 |
{ |
{ |
1133 |
err = (*bottom->notice_input_flushed) (); |
(*bottom->notice_input_flushed) (); |
|
if (err) |
|
|
goto leave; |
|
1134 |
clear_queue (inputq); |
clear_queue (inputq); |
1135 |
} |
} |
1136 |
|
|
1149 |
state.c_lflag &= ~EXTPROC; |
state.c_lflag &= ~EXTPROC; |
1150 |
|
|
1151 |
err = (*bottom->set_bits) (&state); |
err = (*bottom->set_bits) (&state); |
1152 |
if (err) |
if (!err) |
|
goto leave; |
|
|
|
|
|
oldlflag = termstate.c_lflag; |
|
|
termstate = state; |
|
|
|
|
|
if (oldlflag & ICANON) |
|
|
{ |
|
|
if (!(termstate.c_lflag & ICANON)) |
|
|
copy_rawq (); |
|
|
} |
|
|
else |
|
1153 |
{ |
{ |
1154 |
if (termstate.c_lflag & ICANON) |
int oldlflag = termstate.c_lflag; |
1155 |
rescan_inputq (); |
|
1156 |
|
termstate = state; |
1157 |
|
if (oldlflag & ICANON) |
1158 |
|
{ |
1159 |
|
if (!(termstate.c_lflag & ICANON)) |
1160 |
|
copy_rawq (); |
1161 |
|
} |
1162 |
|
else |
1163 |
|
{ |
1164 |
|
if (termstate.c_lflag & ICANON) |
1165 |
|
rescan_inputq (); |
1166 |
|
} |
1167 |
} |
} |
1168 |
|
err = 0; |
1169 |
} |
} |
1170 |
|
|
1171 |
leave: |
leave: |