/* * overlay for the MontaukOS git port. * * The Montauk libc's own is pulled in with #include_next -- this * file only ADDS the POSIX calls git expects and the libc does not declare. * Keeping them here rather than in the libc is deliberate: each one below is * either meaningless on MontaukOS today (there is one user, no groups, no * symlinks in the ramdisk) or needs kernel support that does not exist, and a * libc declaration would promise more than the system delivers. * * Implementations in montauk-compat.c, each documented there with what it * actually does. */ #ifndef _MONTAUK_GIT_UNISTD_H_ #define _MONTAUK_GIT_UNISTD_H_ #include_next #include /* Identity. MontaukOS runs everything as the session user; these report a * single fixed non-root id so that git's "am I root?" and "does this repo * belong to me?" checks answer sensibly (yes, it is mine; no, I am not root). */ uid_t getuid(void); uid_t geteuid(void); gid_t getgid(void); gid_t getegid(void); pid_t getppid(void); int gethostname(char *name, size_t len); /* No interval timers and no SIGALRM delivery, so this arms nothing. * upload-pack's idle timeout is its only caller here, and upload-pack cannot * run without sockets anyway. */ unsigned int alarm(unsigned int seconds); /* Symlinks. Neither the ramdisk nor the VFS represents them, so these fail; * git falls back to writing a regular file with the link text, which is what * core.symlinks=false already asks for. */ int symlink(const char *target, const char *linkpath); ssize_t readlink(const char *path, char *buf, size_t bufsiz); int link(const char *oldpath, const char *newpath); /* Ownership. No uid/gid model to change anything to. */ int chown(const char *path, uid_t owner, gid_t group); int lchown(const char *path, uid_t owner, gid_t group); int fchown(int fd, uid_t owner, gid_t group); /* Durability. The kernel writes through its block cache on close; there is no * per-descriptor flush syscall, so these report success rather than failing a * commit that is in fact on disk. See SYS_FS_SYNC for the whole-filesystem * flush that shutdown uses. */ int fsync(int fd); int fdatasync(int fd); int setsid(void); /* Process groups. MontaukOS has none: a process is its own group, and a * program reading the terminal is by definition the foreground one. These * answer consistently so that progress.c's "am I in the foreground?" test * (tcgetpgrp(fd) == getpgid(0)) says yes and the progress meter is drawn. */ pid_t getpgid(pid_t pid); pid_t getpgrp(void); pid_t tcgetpgrp(int fd); int setpgid(pid_t pid, pid_t pgid); /* The variadic exec forms. The libc has execv/execvp (both of which fail: * MontaukOS spawns rather than execs), so these only repack their arguments * and hand them over -- they exist because `git help` calls execlp() to run * the man viewer. */ int execl(const char *path, const char *arg, ...); int execlp(const char *file, const char *arg, ...); /* Reads a line from the terminal. It CANNOT suppress echo -- see the * implementation. compat/terminal.c calls it for every interactive prompt on * a platform without /dev/tty, which is what MontaukOS is. */ char *getpass(const char *prompt); #endif /* _MONTAUK_GIT_UNISTD_H_ */