github.com/Cloud-Foundations/Dominator@v0.3.4/lib/wsyscall/api.go (about)

     1  package wsyscall
     2  
     3  import "syscall"
     4  
     5  const (
     6  	FALLOC_FL_COLLAPSE_RANGE = 0x8
     7  	FALLOC_FL_INSERT_RANGE   = 0x20
     8  	FALLOC_FL_KEEP_SIZE      = 0x1
     9  	FALLOC_FL_NO_HIDE_STALE  = 0x4
    10  	FALLOC_FL_PUNCH_HOLE     = 0x2
    11  	FALLOC_FL_UNSHARE_RANGE  = 0x40
    12  	FALLOC_FL_ZERO_RANGE     = 0x10
    13  
    14  	MS_BIND = 1 << iota
    15  	MS_RDONLY
    16  
    17  	RUSAGE_CHILDREN = iota
    18  	RUSAGE_SELF
    19  	RUSAGE_THREAD
    20  )
    21  
    22  type Rusage struct {
    23  	Utime    Timeval
    24  	Stime    Timeval
    25  	Maxrss   int64
    26  	Ixrss    int64
    27  	Idrss    int64
    28  	Isrss    int64
    29  	Minflt   int64
    30  	Majflt   int64
    31  	Nswap    int64
    32  	Inblock  int64
    33  	Oublock  int64
    34  	Msgsnd   int64
    35  	Msgrcv   int64
    36  	Nsignals int64
    37  	Nvcsw    int64
    38  	Nivcsw   int64
    39  }
    40  
    41  type Stat_t struct {
    42  	Dev     uint64
    43  	Ino     uint64
    44  	Nlink   uint64
    45  	Mode    uint32
    46  	Uid     uint32
    47  	Gid     uint32
    48  	Rdev    uint64
    49  	Size    int64
    50  	Blksize int64
    51  	Blocks  int64
    52  	Atim    syscall.Timespec
    53  	Mtim    syscall.Timespec
    54  	Ctim    syscall.Timespec
    55  }
    56  
    57  type Timeval struct {
    58  	Sec  int64
    59  	Usec int64
    60  }
    61  
    62  func Dup(oldfd int) (int, error) {
    63  	return dup(oldfd)
    64  }
    65  
    66  func Dup2(oldfd int, newfd int) error {
    67  	return dup2(oldfd, newfd)
    68  }
    69  
    70  func Dup3(oldfd int, newfd int, flags int) error {
    71  	return dup3(oldfd, newfd, flags)
    72  }
    73  
    74  func Fallocate(fd int, mode uint32, off int64, len int64) error {
    75  	return fallocate(fd, mode, off, len)
    76  }
    77  
    78  // GetFileDescriptorLimit returns the current limit and maximum limit on number
    79  // of open file descriptors.
    80  func GetFileDescriptorLimit() (uint64, uint64, error) {
    81  	return getFileDescriptorLimit()
    82  }
    83  
    84  func Ioctl(fd int, request, argp uintptr) error {
    85  	return ioctl(fd, request, argp)
    86  }
    87  
    88  func Lstat(path string, statbuf *Stat_t) error {
    89  	return lstat(path, statbuf)
    90  }
    91  
    92  func Mount(source string, target string, fstype string, flags uintptr,
    93  	data string) error {
    94  	return mount(source, target, fstype, flags, data)
    95  }
    96  
    97  func Getrusage(who int, rusage *Rusage) error {
    98  	return getrusage(who, rusage)
    99  }
   100  
   101  func Reboot() error {
   102  	return reboot()
   103  }
   104  
   105  func SetAllGid(gid int) error {
   106  	return setAllGid(gid)
   107  }
   108  
   109  func SetAllUid(uid int) error {
   110  	return setAllUid(uid)
   111  }
   112  
   113  // SetMyPriority sets the priority of the current process, for all OS threads.
   114  // On platforms which do not support changing the process priority, an error is
   115  // always returned.
   116  func SetMyPriority(priority int) error {
   117  	return setMyPriority(priority)
   118  }
   119  
   120  // SetNetNamespace is a safe wrapper for the Linux setns(fd, CLONE_NEWNET)
   121  // system call. On Linux it will lock the current goroutine to an OS thread and
   122  // set the network namespace to the specified file descriptor. On failure or on
   123  // other platforms an error is returned.
   124  func SetNetNamespace(fd int) error {
   125  	return setNetNamespace(fd)
   126  }
   127  
   128  func Stat(path string, statbuf *Stat_t) error {
   129  	return stat(path, statbuf)
   130  }
   131  
   132  func Sync() error {
   133  	return sync()
   134  }
   135  
   136  // UnshareMountNamespace is a safe wrapper for the Linux unshare(CLONE_NEWNS)
   137  // system call. On Linux it will lock the current goroutine to an OS thread and
   138  // unshare the mount namespace (the thread will have a private copy of the
   139  // previous mount namespace). On failure or on other platforms an error is
   140  // returned.
   141  func UnshareMountNamespace() error {
   142  	return unshareMountNamespace()
   143  }
   144  
   145  // UnshareNetNamespace is a safe wrapper for the Linux unshare(CLONE_NEWNET)
   146  // system call. On Linux it will lock the current goroutine to an OS thread and
   147  // unshare the network namespace (the thread will have a fresh network
   148  // namespace). The file descriptor for the new network namespace and the Linux
   149  // thread ID are returned.
   150  // On failure or on other platforms an error is returned.
   151  func UnshareNetNamespace() (fd int, tid int, err error) {
   152  	return unshareNetNamespace()
   153  }