big <utmp.h>-inspired netbsd switch

import/switch of:
init, getty, reboot, halt, shutdown, wall, last

changes:
	. change reboot() call to netbsd prototype and args
	. allows pristine <utmp.h>
	. use clean <sys/reboot.h> instead of <minix/reboot.h>
	. implement TIOCSCTTY for use by getty so getty can get
	  controlling terminal from init's child(ren)
	. allow NULL envp for exec

Change-Id: I5ca02cb4230857140c08794bbfeba7df982c58a3
This commit is contained in:
Ben Gras
2013-09-09 13:20:18 +00:00
committed by Lionel Sambuc
parent fa06ff0ee3
commit a06e2ab395
93 changed files with 8096 additions and 2465 deletions

View File

@@ -355,20 +355,14 @@ updwtmpx(const char *file, const struct utmpx *utx)
#else
if ((fd = open(file, O_CREAT|O_WRONLY, 0644)) < 0)
return -1;
if (flock(fd, LOCK_EX) < 0)
return -1;
#endif
(void)memset(&ut, 0, sizeof(ut));
ut.ut_type = SIGNATURE;
(void)memcpy(ut.ut_user, vers, sizeof(vers));
if (write(fd, &ut, sizeof(ut)) == -1)
goto failed;
} else {
#ifdef __minix
if (flock(fd, LOCK_SH) < 0 )
return -1;
#endif
}
if (write(fd, utx, sizeof(*utx)) == -1)
goto failed;
if (close(fd) == -1)
@@ -455,10 +449,6 @@ getlastlogx(const char *fname, uid_t uid, struct lastlogx *ll)
if (db == NULL)
return NULL;
#ifdef __minix
if (flock(db->fd(db), LOCK_SH) < 0)
return NULL;
#endif
key.data = &uid;
key.size = sizeof(uid);
@@ -503,10 +493,6 @@ updlastlogx(const char *fname, uid_t uid, struct lastlogx *ll)
if (db == NULL)
return -1;
#ifdef __minix
if (flock(db->fd(db), LOCK_EX) < 0)
return -1;
#endif
key.data = &uid;
key.size = sizeof(uid);
data.data = ll;

View File

@@ -11,7 +11,7 @@
#include <string.h>
#include <sys/reboot.h>
int reboot(int how)
int reboot(int how, char *bootstr)
{
message m;

View File

@@ -99,7 +99,7 @@ void minix_stack_params(const char *path, char * const *argv, char * const *envp
(*argc)++;
}
for (p = envp; *p != NULL; p++) {
for (p = envp; p && *p != NULL; p++) {
size_t const n = sizeof(*p) + strlen(*p) + 1;
*stack_size += n;
if (*stack_size < n) {
@@ -156,7 +156,7 @@ void minix_stack_fill(const char *path, int argc, char * const *argv,
}
*fpw++ = NULL;
for (p = envp; *p != NULL; p++) {
for (p = envp; p && *p != NULL; p++) {
size_t const n = strlen(*p) + 1;
*fpw++= (char *)(*vsp + (fp - frame));
memcpy(fp, *p, n);

View File

@@ -244,7 +244,7 @@ MAN+= accept.2 access.2 acct.2 bind.2 brk.2 chdir.2 \
mprotect.2 mremap.2 msgctl.2 msgget.2 msgrcv.2 msgsnd.2 msync.2 \
munmap.2 nanosleep.2 nfssvc.2 ntp_adjtime.2 open.2 pathconf.2 pipe.2
.else
MAN+= adjtime.2 clock_settime.2 getvfsstat.2 pipe.2 getrusage.2
MAN+= adjtime.2 clock_settime.2 getvfsstat.2 pipe.2 getrusage.2 reboot.2
.endif # !defined(__MINIX)
.if !defined(__MINIX)
MAN+= pmc_control.2 poll.2 posix_fadvise.2 profil.2 ptrace.2 __quotactl.2 \

View File

@@ -146,10 +146,11 @@ CPPFLAGS.${i}+= -I${LIBCDIR}/locale
.for i in access.c brk.c close.c environ.c execve.c fork.c fsync.c \
getgid.c getpid.c geteuid.c getuid.c gettimeofday.c getvfsstat.c \
init.c link.c loadname.c lseek.c lseek64.c _mcontext.c mknod.c \
mmap.c nanosleep.c open.c pread.c pwrite.c read.c reboot.c sbrk.c \
mmap.c nanosleep.c open.c pread.c pwrite.c read.c sbrk.c \
select.c setuid.c sigprocmask.c stack_utils.c stat.c stime.c \
syscall.c _ucontext.c umask.c unlink.c waitpid.c write.c \
brksize.S _do_kernel_call_intr.S get_minix_kerninfo.S _ipc.S ucontext.S
brksize.S _do_kernel_call_intr.S get_minix_kerninfo.S _ipc.S ucontext.S \
kill.c
.PATH.c: ${LIBCDIR}/sys-minix
.PATH.S: ${ARCHDIR}/sys-minix
SRCS+= ${i}

View File

@@ -42,7 +42,7 @@ SRCS+= efun.c \
passwd.c pw_scan.c pidfile.c pidlock.c pty.c \
raise_default_signal.c \
secure_path.c stat_flags.c \
strpct.c ttyaction.c \
strpct.c ttyaction.c ttymsg.c \
MAN= efun.3 \
getmntopts.3 \