gopkg.in/ro-ag/posix.v1@v1.0.6/const.go (about)

     1  //go:build darwin || linux
     2  
     3  package posix
     4  
     5  import (
     6  	"syscall"
     7  	"unsafe"
     8  )
     9  
    10  //goland:noinspection GoSnakeCaseUsage
    11  const (
    12  	EINVAL     = syscall.EINVAL
    13  	EAGAIN     = syscall.EAGAIN
    14  	ENOENT     = syscall.ENOENT
    15  	EFAULT     = syscall.EFAULT
    16  	O_RDWR     = syscall.O_RDWR     // open for reading and writing
    17  	O_CREAT    = syscall.O_CREAT    // create if nonexistent
    18  	O_EXCL     = syscall.O_EXCL     // error if already exists
    19  	O_NOFOLLOW = syscall.O_NOFOLLOW // don't follow symlinks
    20  	O_RDONLY   = syscall.O_RDONLY   // open for reading only
    21  	O_WRONLY   = syscall.O_WRONLY   // open for writing only
    22  	O_ACCMODE  = syscall.O_ACCMODE  // mask for modes O_RDONLY & O_WRONLY
    23  	O_CLOEXEC  = syscall.O_CLOEXEC
    24  )
    25  
    26  //goland:noinspection GoSnakeCaseUsage
    27  const (
    28  	PROT_NONE  = syscall.PROT_NONE  // The memory cannot be accessed at all.
    29  	PROT_READ  = syscall.PROT_READ  // The memory can be read.
    30  	PROT_WRITE = syscall.PROT_WRITE // The memory can be modified.
    31  	PROT_EXEC  = syscall.PROT_EXEC  // The memory can be executed.
    32  	PROT_RDWR  = PROT_READ | PROT_WRITE
    33  )
    34  
    35  /*
    36  The Mode Bits for Access Permission
    37  The file mode, stored in the st_mode field of the file attributes, contains two kinds of information: the file type code, and the access permission bits. This section discusses only the access permission bits, which control who can read or write the file. See Testing File Type, for information about the file type code.
    38  All the symbols listed in this section are defined in the header file sys/stat.h.
    39  These symbolic constants are defined for the file mode bits that control access permission for the file:
    40  */
    41  //goland:noinspection GoSnakeCaseUsage
    42  const (
    43  	S_IRUSR    = syscall.S_IRUSR  // Read permission bit for the owner of the file. On many systems this bit is 0400.
    44  	S_IREAD    = syscall.S_IREAD  // Deprecated: S_IREAD is an Obsolete synonym provided for BSD compatibility
    45  	S_IWUSR    = syscall.S_IWUSR  // Write permission bit for the owner of the file. Usually 0200.
    46  	S_IWRITE   = syscall.S_IWRITE // Deprecated: S_IWRITE is an obsolete synonym provided for BSD compatibility.
    47  	S_IXUSR    = syscall.S_IXUSR  // Execute (for ordinary files) or search (for directories) permission bit for the owner of the file. Usually 0100.
    48  	S_IEXEC    = syscall.S_IEXEC  // Deprecated: S_IEXEC is an obsolete synonym provided for BSD compatibility.
    49  	S_IRWXU    = syscall.S_IRWXU  // This is equivalent to ‘(S_IRUSR | S_IWUSR | S_IXUSR)’.
    50  	S_IRGRP    = syscall.S_IRGRP  // Read permission bit for the group owner of the file. Usually 040.
    51  	S_IWGRP    = syscall.S_IWGRP  // Write permission bit for the group owner of the file. Usually 020.
    52  	S_IXGRP    = syscall.S_IXGRP  // Execute or search permission bit for the group owner of the file. Usually 010.
    53  	S_IRWXG    = syscall.S_IRWXG  // This is equivalent to ‘(S_IRGRP | S_IWGRP | S_IXGRP)’.
    54  	S_IROTH    = syscall.S_IROTH  // Read permission bit for other users. Usually 04.
    55  	S_IWOTH    = syscall.S_IWOTH  // Write permission bit for other users. Usually 02.
    56  	S_IXOTH    = syscall.S_IXOTH  // Execute or search permission bit for other users. Usually 01.
    57  	S_IRWXO    = syscall.S_IRWXO  // This is equivalent to ‘(S_IROTH | S_IWOTH | S_IXOTH)’.
    58  	S_ISUID    = syscall.S_ISUID  // This is the set-user-ID on execute bit, usually 04000. See How Change Persona.
    59  	S_ISGID    = syscall.S_ISGID  // This is the set-group-ID on execute bit, usually 02000. See How Change Persona.
    60  	S_ISVTX    = syscall.S_ISVTX  // This is the sticky bit, usually 01000.
    61  	FP_SPECIAL = 1
    62  )
    63  
    64  //goland:noinspection GoSnakeCaseUsage
    65  const (
    66  	S_IFMT   = syscall.S_IFMT   // [XSI] type of file mask
    67  	S_IFIFO  = syscall.S_IFIFO  // [XSI] named pipe (fifo)
    68  	S_IFCHR  = syscall.S_IFCHR  // [XSI] character special
    69  	S_IFDIR  = syscall.S_IFDIR  // [XSI] directory
    70  	S_IFBLK  = syscall.S_IFBLK  // [XSI] block special
    71  	S_IFREG  = syscall.S_IFREG  // [XSI] regular
    72  	S_IFLNK  = syscall.S_IFLNK  // [XSI] symbolic link
    73  	S_IFSOCK = syscall.S_IFSOCK // [XSI] socket
    74  )
    75  
    76  //goland:noinspection GoSnakeCaseUsage
    77  const (
    78  	MFD_ALLOW_SEALING = 0x2
    79  	MFD_CLOEXEC       = 0x1
    80  	MFD_HUGETLB       = 0x4
    81  	MFD_HUGE_16GB     = -0x78000000
    82  	MFD_HUGE_16MB     = 0x60000000
    83  	MFD_HUGE_1GB      = 0x78000000
    84  	MFD_HUGE_1MB      = 0x50000000
    85  	MFD_HUGE_256MB    = 0x70000000
    86  	MFD_HUGE_2GB      = 0x7c000000
    87  	MFD_HUGE_2MB      = 0x54000000
    88  	MFD_HUGE_32MB     = 0x64000000
    89  	MFD_HUGE_512KB    = 0x4c000000
    90  	MFD_HUGE_512MB    = 0x74000000
    91  	MFD_HUGE_64KB     = 0x40000000
    92  	MFD_HUGE_8MB      = 0x5c000000
    93  	MFD_HUGE_MASK     = 0x3f
    94  	MFD_HUGE_SHIFT    = 0x1a
    95  	MCL_CURRENT       = syscall.MCL_CURRENT
    96  	MCL_FUTURE        = syscall.MCL_FUTURE
    97  	MADV_DONTNEED     = syscall.MADV_DONTNEED
    98  	MADV_NORMAL       = syscall.MADV_NORMAL
    99  	MADV_RANDOM       = syscall.MADV_RANDOM
   100  	MADV_SEQUENTIAL   = syscall.MADV_SEQUENTIAL
   101  	MADV_WILLNEED     = syscall.MADV_WILLNEED
   102  	MAP_ANON          = syscall.MAP_ANON // Don't use a file.
   103  	MAP_ANONYMOUS     = syscall.MAP_ANON // Don't use a file.
   104  	MAP_FILE          = syscall.MAP_FILE
   105  	MAP_FIXED         = syscall.MAP_FIXED // Interpret address exactly.
   106  	MAP_NORESERVE     = syscall.MAP_NORESERVE
   107  	MAP_PRIVATE       = syscall.MAP_PRIVATE // Changes are private.
   108  	MAP_SHARED        = syscall.MAP_SHARED  // Share changes.
   109  	MS_ASYNC          = syscall.MS_ASYNC    // Perform synchronous page faults for the mapping.
   110  	MS_INVALIDATE     = syscall.MS_INVALIDATE
   111  	MS_SYNC           = syscall.MS_SYNC
   112  	NAME_MAX          = syscall.NAME_MAX
   113  )
   114  
   115  // File Fcntl
   116  //goland:noinspection GoSnakeCaseUsage
   117  const (
   118  	F_GETFD    = syscall.F_GETFD
   119  	F_SETFD    = syscall.F_SETFD
   120  	FD_CLOEXEC = syscall.FD_CLOEXEC
   121  )
   122  
   123  var (
   124  	errEAGAIN error = syscall.EAGAIN
   125  	errEINVAL error = syscall.EINVAL
   126  	errENOENT error = syscall.ENOENT
   127  )
   128  
   129  func errnoErr(e syscall.Errno) error {
   130  	switch e {
   131  	case 0:
   132  		return nil
   133  	case EAGAIN:
   134  		return errEAGAIN
   135  	case EINVAL:
   136  		return errEINVAL
   137  	case ENOENT:
   138  		return errENOENT
   139  	}
   140  	return e
   141  }
   142  
   143  type Errno = syscall.Errno
   144  
   145  // _unsafeSlice is the runtime representation of a slice.
   146  type _unsafeSlice struct {
   147  	Data unsafe.Pointer
   148  	Len  int
   149  	Cap  int
   150  }