简体   繁体   English

windows 中的系统调用库

[英]Syscall library in windows

Is it possible to translate the following functions in syscall into something in windows.h ?是否可以将syscall中的以下函数转换为windows.h中的内容? If so, someone with information can help me, I can't find anything on google.如果是这样,有信息的人可以帮助我,我在谷歌上找不到任何东西。

static inline int __setns(int fd, int nstype) {
    return syscall(__NR_setns, fd, nstype);

}

static inline int __unshare(int flags) {
    return syscall(__NR_unshare, flags);
}

static inline int __accept4(int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) {
    return syscall(__NR_accept4, sockfd, addr, addrlen, flags);
}

static inline int __dup3(int oldfd, int newfd, int flags) {
    return syscall(__NR_dup3, oldfd, newfd, flags);
}

static inline ssize_t __readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz) {
    return syscall(__NR_readlinkat, dirfd, pathname, buf, bufsiz);
}

static inline int __symlinkat(const char *target, int newdirfd, const char *linkpath) {
    return syscall(__NR_symlinkat, target, newdirfd, linkpath);
}

static inline int __linkat(int olddirfd, const char *oldpath,
        int newdirfd, const char *newpath, int flags) {
    return syscall(__NR_linkat, olddirfd, oldpath, newdirfd, newpath, flags);
}

static inline int __inotify_init1(int flags) {
    return syscall(__NR_inotify_init1, flags);
}

static inline int __faccessat(int dirfd, const char *pathname, int mode, int flags) {
    return syscall(__NR_faccessat, dirfd, pathname, mode, flags);
}

No, it's not possible.不,这是不可能的。 Those are Linux specific system calls, and there is no direct "translation" on other operating systems.这些是 Linux 特定的系统调用,在其他操作系统上没有直接的“翻译”。

The only thing you can do under Windows is to try and emulate those system calls, but that can only go so far and you will not be able to emulate all of them.在 Windows 下,您唯一能做的就是尝试模拟这些系统调用,但到目前为止,这只能是 go 并且您将无法模拟所有这些调用。 A great example of this is Cygwin, which emulates a lot of standard Linux syscalls on windows, providing the the unistd.h header just like in any Linux system. A great example of this is Cygwin, which emulates a lot of standard Linux syscalls on windows, providing the the unistd.h header just like in any Linux system.

If you want to translate something outside the unistd.h header provided by Cygwin I'd say that's not possible unfortunately.如果你想翻译 Cygwin 提供的unistd.h header 之外的东西,我想说那是不可能的。 You could try writing similar wrappers, but you're not going to really get the same syscall.您可以尝试编写类似的包装器,但您不会真正获得相同的系统调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM