feat: ports - git port
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* <sys/ioctl.h> for the MontaukOS git port.
|
||||
*
|
||||
* git uses exactly one ioctl: TIOCGWINSZ, to find the terminal width for
|
||||
* `git column`, the progress meter and `git help -a`. MontaukOS has no ioctl
|
||||
* syscall, so the request fails and git falls back to its default 80 columns.
|
||||
*
|
||||
* Implementation in montauk-compat.c.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_IOCTL_H_
|
||||
#define _MONTAUK_GIT_SYS_IOCTL_H_
|
||||
|
||||
#define TIOCGWINSZ 0x5413
|
||||
|
||||
struct winsize {
|
||||
unsigned short ws_row;
|
||||
unsigned short ws_col;
|
||||
unsigned short ws_xpixel;
|
||||
unsigned short ws_ypixel;
|
||||
};
|
||||
|
||||
int ioctl(int fd, unsigned long request, ...);
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_IOCTL_H_ */
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* <sys/resource.h> stub for the MontaukOS git port.
|
||||
*
|
||||
* Reached only through git-compat-util.h's unconditional include and
|
||||
* trace2's resource accounting, which is compiled out without getrusage.
|
||||
* MontaukOS keeps no per-process resource accounting, so getrlimit reports
|
||||
* "unlimited" and everything else fails.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_RESOURCE_H_
|
||||
#define _MONTAUK_GIT_SYS_RESOURCE_H_
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define RLIMIT_NOFILE 7
|
||||
|
||||
typedef unsigned long rlim_t;
|
||||
|
||||
#define RLIM_INFINITY (~(rlim_t)0)
|
||||
|
||||
struct rlimit {
|
||||
rlim_t rlim_cur;
|
||||
rlim_t rlim_max;
|
||||
};
|
||||
|
||||
struct rusage {
|
||||
struct timeval ru_utime;
|
||||
struct timeval ru_stime;
|
||||
long ru_maxrss;
|
||||
long ru_minflt;
|
||||
long ru_majflt;
|
||||
long ru_inblock;
|
||||
long ru_oublock;
|
||||
long ru_nvcsw;
|
||||
long ru_nivcsw;
|
||||
};
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
|
||||
static inline int getrlimit(int resource, struct rlimit *rlim)
|
||||
{
|
||||
(void) resource;
|
||||
if (rlim) {
|
||||
rlim->rlim_cur = RLIM_INFINITY;
|
||||
rlim->rlim_max = RLIM_INFINITY;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int setrlimit(int resource, const struct rlimit *rlim)
|
||||
{
|
||||
(void) resource; (void) rlim;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int getrusage(int who, struct rusage *usage)
|
||||
{
|
||||
(void) who; (void) usage;
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_RESOURCE_H_ */
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* <sys/socket.h> for the MontaukOS git port.
|
||||
*
|
||||
* MontaukOS does have TCP -- the kernel exposes it as IPC handles through
|
||||
* montauk::socket(), not as BSD descriptors -- but nothing bridges the two
|
||||
* into the fd space that read()/write() use, and git's transports assume a
|
||||
* descriptor it can hand to a sub-process. Until that bridge exists, every
|
||||
* call here fails with ENOSYS, which surfaces as "unable to connect" from
|
||||
* `git clone git://...` rather than as a crash.
|
||||
*
|
||||
* That leaves the local transports -- init, add, commit, log, diff, and
|
||||
* clone/fetch/push against a path on disk -- which are what this port is for.
|
||||
*
|
||||
* Implementations in montauk-compat.c.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_SOCKET_H_
|
||||
#define _MONTAUK_GIT_SYS_SOCKET_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef unsigned int socklen_t;
|
||||
typedef unsigned short sa_family_t;
|
||||
|
||||
#define AF_UNSPEC 0
|
||||
#define AF_UNIX 1
|
||||
#define AF_LOCAL 1
|
||||
#define AF_INET 2
|
||||
#define AF_INET6 10
|
||||
|
||||
#define PF_UNSPEC AF_UNSPEC
|
||||
#define PF_UNIX AF_UNIX
|
||||
#define PF_INET AF_INET
|
||||
#define PF_INET6 AF_INET6
|
||||
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
|
||||
#define SOL_SOCKET 1
|
||||
|
||||
#define SO_REUSEADDR 2
|
||||
#define SO_ERROR 4
|
||||
#define SO_KEEPALIVE 9
|
||||
#define SO_LINGER 13
|
||||
|
||||
#define SHUT_RD 0
|
||||
#define SHUT_WR 1
|
||||
#define SHUT_RDWR 2
|
||||
|
||||
#define MSG_PEEK 2
|
||||
|
||||
struct sockaddr {
|
||||
sa_family_t sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
/* Large enough for sockaddr_in6, aligned like the real thing. */
|
||||
struct sockaddr_storage {
|
||||
sa_family_t ss_family;
|
||||
unsigned long __ss_align;
|
||||
char __ss_padding[112];
|
||||
};
|
||||
|
||||
struct linger {
|
||||
int l_onoff;
|
||||
int l_linger;
|
||||
};
|
||||
|
||||
int socket(int domain, int type, int protocol);
|
||||
int connect(int fd, const struct sockaddr *addr, socklen_t len);
|
||||
int bind(int fd, const struct sockaddr *addr, socklen_t len);
|
||||
int listen(int fd, int backlog);
|
||||
int accept(int fd, struct sockaddr *addr, socklen_t *len);
|
||||
int shutdown(int fd, int how);
|
||||
int setsockopt(int fd, int level, int name, const void *val, socklen_t len);
|
||||
int getsockopt(int fd, int level, int name, void *val, socklen_t *len);
|
||||
int getsockname(int fd, struct sockaddr *addr, socklen_t *len);
|
||||
int getpeername(int fd, struct sockaddr *addr, socklen_t *len);
|
||||
ssize_t send(int fd, const void *buf, size_t len, int flags);
|
||||
ssize_t recv(int fd, void *buf, size_t len, int flags);
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_SOCKET_H_ */
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* <sys/stat.h> overlay for the MontaukOS git port.
|
||||
*
|
||||
* The libc header comes in through #include_next; this only adds the mode
|
||||
* bits it leaves out. They are not idle definitions:
|
||||
*
|
||||
* S_ISUID builtin/fast-import.c borrows it as a private in-memory flag
|
||||
* (NO_DELTA), so it must exist even though no file ever carries
|
||||
* it on MontaukOS.
|
||||
* S_ISGID setup.c uses it for shared-repository directory modes.
|
||||
* S_ISVTX referenced when normalising modes read from an index.
|
||||
*
|
||||
* The S_IF* type constants below round out the set for the same reason: git
|
||||
* masks against them. MontaukOS never reports a fifo, socket or block device
|
||||
* from stat(), and the libc's S_ISFIFO/S_ISSOCK/S_ISBLK are hard-coded false
|
||||
* to say exactly that -- they are deliberately left alone here.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_STAT_H_
|
||||
#define _MONTAUK_GIT_SYS_STAT_H_
|
||||
|
||||
#include_next <sys/stat.h>
|
||||
|
||||
#ifndef S_ISUID
|
||||
#define S_ISUID 04000
|
||||
#endif
|
||||
#ifndef S_ISGID
|
||||
#define S_ISGID 02000
|
||||
#endif
|
||||
#ifndef S_ISVTX
|
||||
#define S_ISVTX 01000
|
||||
#endif
|
||||
|
||||
#ifndef S_IFIFO
|
||||
#define S_IFIFO 0010000
|
||||
#endif
|
||||
#ifndef S_IFBLK
|
||||
#define S_IFBLK 0060000
|
||||
#endif
|
||||
#ifndef S_IFSOCK
|
||||
#define S_IFSOCK 0140000
|
||||
#endif
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_STAT_H_ */
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* <sys/statvfs.h> stub for the MontaukOS git port.
|
||||
*
|
||||
* git calls statvfs() in one place: fsmonitor's "is this a network
|
||||
* filesystem" probe, which this port does not build. MontaukOS exposes no
|
||||
* filesystem statistics syscall, so the call fails and callers take their
|
||||
* "unknown filesystem" branch.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_STATVFS_H_
|
||||
#define _MONTAUK_GIT_SYS_STATVFS_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
|
||||
typedef unsigned long fsblkcnt_t;
|
||||
typedef unsigned long fsfilcnt_t;
|
||||
|
||||
struct statvfs {
|
||||
unsigned long f_bsize;
|
||||
unsigned long f_frsize;
|
||||
fsblkcnt_t f_blocks;
|
||||
fsblkcnt_t f_bfree;
|
||||
fsblkcnt_t f_bavail;
|
||||
fsfilcnt_t f_files;
|
||||
fsfilcnt_t f_ffree;
|
||||
fsfilcnt_t f_favail;
|
||||
unsigned long f_fsid;
|
||||
unsigned long f_flag;
|
||||
unsigned long f_namemax;
|
||||
unsigned long f_type;
|
||||
};
|
||||
|
||||
static inline int statvfs(const char *path, struct statvfs *buf)
|
||||
{
|
||||
(void) path; (void) buf;
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int fstatvfs(int fd, struct statvfs *buf)
|
||||
{
|
||||
(void) fd; (void) buf;
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_STATVFS_H_ */
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* <sys/time.h> overlay for the MontaukOS git port.
|
||||
*
|
||||
* Adds the ITIMER_* selectors on top of the libc header. MontaukOS has no
|
||||
* interval timers, so the port is built NO_SETITIMER=1 and NO_STRUCT_ITIMERVAL=1
|
||||
* -- git supplies its own struct itimerval and a setitimer() that returns
|
||||
* success without arming anything. The selectors still have to exist, because
|
||||
* the call sites name them (builtin/log.c's early-output timer, progress.c).
|
||||
*
|
||||
* What that costs: `git log`'s half-second early-output nudge never fires, so
|
||||
* the first commits appear when the traversal produces them rather than on a
|
||||
* timer. Nothing depends on it for correctness.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_TIME_H_
|
||||
#define _MONTAUK_GIT_SYS_TIME_H_
|
||||
|
||||
#include_next <sys/time.h>
|
||||
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_TIME_H_ */
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* <sys/types.h> overlay for the MontaukOS git port.
|
||||
*
|
||||
* Adds the historical BSD type aliases on top of the libc header. git's
|
||||
* compat/inet_ntop.c and compat/inet_pton.c come from the ISC resolver and
|
||||
* are written in terms of u_char/u_int; both are compiled here because the
|
||||
* port sets NO_INET_NTOP=1 / NO_INET_PTON=1.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_TYPES_H_
|
||||
#define _MONTAUK_GIT_SYS_TYPES_H_
|
||||
|
||||
#include_next <sys/types.h>
|
||||
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
|
||||
typedef char *caddr_t;
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_TYPES_H_ */
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* <sys/un.h> for the MontaukOS git port.
|
||||
*
|
||||
* Included unconditionally by git-compat-util.h. The port builds with
|
||||
* NO_UNIX_SOCKETS=1, so nothing constructs one of these -- the type just has
|
||||
* to exist.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_UN_H_
|
||||
#define _MONTAUK_GIT_SYS_UN_H_
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
struct sockaddr_un {
|
||||
sa_family_t sun_family;
|
||||
char sun_path[108];
|
||||
};
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_UN_H_ */
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* <sys/utsname.h> for the MontaukOS git port.
|
||||
*
|
||||
* Used by help.c for the "uname" lines of `git version --build-options` and
|
||||
* by the bugreport builtin. Answers static MontaukOS strings; there is no
|
||||
* kernel interface for the release/version fields yet.
|
||||
*
|
||||
* Implementation in montauk-compat.c.
|
||||
*/
|
||||
#ifndef _MONTAUK_GIT_SYS_UTSNAME_H_
|
||||
#define _MONTAUK_GIT_SYS_UTSNAME_H_
|
||||
|
||||
struct utsname {
|
||||
char sysname[65];
|
||||
char nodename[65];
|
||||
char release[65];
|
||||
char version[65];
|
||||
char machine[65];
|
||||
};
|
||||
|
||||
int uname(struct utsname *buf);
|
||||
|
||||
#endif /* _MONTAUK_GIT_SYS_UTSNAME_H_ */
|
||||
Reference in New Issue
Block a user