Documentation
¶
Overview ¶
Package freax provides operating system functions for Linux.
Index ¶
- Constants
- Variables
- func ErrnoFromSyscallErrno(err error) error
- func FDRead(fd uintptr, p []byte) (n int, err error)
- func FDReadAll(fd uintptr) ([]byte, error)
- func FcntlCheckfl(fd uintptr, flag int) (bool, error)
- func FcntlGetfl(fd uintptr) (int, error)
- func FileContains(path, substr string) (bool, error)
- func FileContainsLine(path, line string) (bool, error)
- func FileCountLines(path string) (int, error)
- func FileModeIsBlk(m FileMode) bool
- func FileModeIsChr(m FileMode) bool
- func FileModeIsFifo(m FileMode) bool
- func FileModeIsLnk(m FileMode) bool
- func FileModeIsReg(m FileMode) bool
- func FileModeIsSet(mode, m FileMode) bool
- func FileModeIsSetPath(path string, m FileMode) (bool, error)
- func FileModeIsSock(m FileMode) bool
- func FileModeSetPath(path string, m FileMode) error
- func FileModeUnsetPath(path string, m FileMode) error
- func FlockGetRead(fd uintptr) (bool, error)
- func FlockGetWrite(fd uintptr) (bool, error)
- func FlockSetRead(fd uintptr) error
- func FlockSetReadWait(fd uintptr) error
- func FlockSetWrite(fd uintptr) error
- func FlockSetWriteWait(fd uintptr) error
- func FlockUnlock(fd uintptr) error
- func FlockUnlockWait(fd uintptr) error
- func GetFileGroup(file string) (*user.Group, error)deprecated
- func GetFileOwner(file string) (*user.User, error)deprecated
- func IsBlkPath(path string) (bool, error)
- func IsChrPath(path string) (bool, error)
- func IsDir(m FileMode) bool
- func IsDirPath(path string) (bool, error)
- func IsFifoPath(path string) (bool, error)
- func IsLnkPath(path string) (bool, error)
- func IsPathExists(path string) (bool, error)
- func IsRegPath(path string) (bool, error)
- func IsSockPath(path string) (bool, error)
- func ListDir(name string, recursive bool, hidden bool) ([]string, error)
- func ListFiles(path string) ([]string, error)
- func NewErrno(n int) error
- func PIDCheck(path string) (bool, error)
- func PIDCreate(path string, perm uint32) error
- func PIDRead(path string) (int, error)
- func PIDRemove(path string) error
- func ReadAll(name string) ([]byte, error)
- func Shred(path string, n int, random bool) (int64, error)
- func ShredLock(path string, n int, random bool) (int64, error)
- func ShredLockWait(path string, n int, random bool) (int64, error)
- func Truncate(file *os.File) error
- func TruncatePath(path string) error
- func Write(name string, data []byte, perm uint32) error
- func WriteSync(name string, data []byte, perm uint32) error
- type Errno
- type File
- func (f *File) Close() error
- func (f *File) Fd() uintptr
- func (f *File) Lock() error
- func (f *File) Read(p []byte) (n int, err error)
- func (f *File) ReadByte() (byte, error)
- func (f *File) Seek(offset int64, whence int) (int64, error)
- func (f *File) Stat() (*FileInfo, error)
- func (f *File) Sync() error
- func (f *File) Unlock() error
- func (f *File) Write(p []byte) (n int, err error)
- func (f *File) WriteByte(c byte) error
- func (f *File) WriteString(s string) (n int, err error)
- type FileInfo
- type FileMode
- type FileType
- type User
Constants ¶
const ( // Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified. O_RDONLY = unix.O_RDONLY // open the file read-only. O_WRONLY = unix.O_WRONLY // open the file write-only. O_RDWR = unix.O_RDWR // open the file read-write. // The remaining values may be or'ed in to control behavior. O_APPEND = unix.O_APPEND // append data to the file when writing. O_CREATE = unix.O_CREAT // create a new file if none exists. O_EXCL = unix.O_EXCL // used with O_CREATE, file must not exist. O_SYNC = unix.O_SYNC // open for synchronous I/O. O_TRUNC = unix.O_TRUNC // truncate regular writable file when opened. )
Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
const ( SEEK_SET = unix.SEEK_SET // seek relative to the origin of the file SEEK_CUR = unix.SEEK_CUR // seek relative to the current offset SEEK_END = unix.SEEK_END // seek relative to the end )
Seek whence values.
const (
PasswdFile = "/etc/passwd"
)
Variables ¶
var ( EPERM = &Errno{"EPERM", 1, "Operation not permitted"} ENOENT = &Errno{"ENOENT", 2, "No such file or directory"} ESRCH = &Errno{"ESRCH", 3, "No such process"} EINTR = &Errno{"EINTR", 4, "Interrupted system call"} EIO = &Errno{"EIO", 5, "I/O error"} ENXIO = &Errno{"ENXIO", 6, "No such device or address"} E2BIG = &Errno{"E2BIG", 7, "Argument list too long"} ENOEXEC = &Errno{"ENOEXEC", 8, "Exec format error"} EBADF = &Errno{"EBADF", 9, "Bad file number"} ECHILD = &Errno{"ECHILD", 10, "No child processes"} EAGAIN = &Errno{"EAGAIN", 11, "Try again"} ENOMEM = &Errno{"ENOMEM", 12, "Out of memory"} EACCES = &Errno{"EACCES", 13, "Permission denied"} EFAULT = &Errno{"EFAULT", 14, "Bad address"} ENOTBLK = &Errno{"ENOTBLK", 15, "Block device required"} EBUSY = &Errno{"EBUSY", 16, "Device or resource busy"} EEXIST = &Errno{"EEXIST", 17, "File exists"} EXDEV = &Errno{"EXDEV", 18, "Cross-device link"} ENODEV = &Errno{"ENODEV", 19, "No such device"} ENOTDIR = &Errno{"ENOTDIR", 20, "Not a directory"} EISDIR = &Errno{"EISDIR", 21, "Is a directory"} EINVAL = &Errno{"EINVAL", 22, "Invalid argument"} ENFILE = &Errno{"ENFILE", 23, "File table overflow"} EMFILE = &Errno{"EMFILE", 24, "Too many open files"} ENOTTY = &Errno{"ENOTTY", 25, "Not a typewriter"} ETXTBSY = &Errno{"ETXTBSY", 26, "Text file busy"} EFBIG = &Errno{"EFBIG", 27, "File too large"} ENOSPC = &Errno{"ENOSPC", 28, "No space left on device"} ESPIPE = &Errno{"ESPIPE", 29, "Illegal seek"} EROFS = &Errno{"EROFS", 30, "Read-only file system"} EMLINK = &Errno{"EMLINK", 31, "Too many links"} EPIPE = &Errno{"EPIPE", 32, "Broken pipe"} EDOM = &Errno{"EDOM", 33, "Math argument out of domain of func"} ERANGE = &Errno{"ERANGE", 34, "Math result not representable"} EDEADLK = &Errno{"EDEADLK", 35, "Resource deadlock would occur"} ENAMETOOLONG = &Errno{"ENAMETOOLONG", 36, "File name too long"} ENOLCK = &Errno{"ENOLCK", 37, "No record locks available"} ENOSYS = &Errno{"ENOSYS", 38, "Invalid system call number"} ENOTEMPTY = &Errno{"ENOTEMPTY", 39, "Directory not empty"} ELOOP = &Errno{"ELOOP", 40, "Too many symbolic links encountered"} ENOMSG = &Errno{"ENOMSG", 42, "No message of desired type"} EIDRM = &Errno{"EIDRM", 43, "Identifier removed"} ECHRNG = &Errno{"ECHRNG", 44, "Channel number out of range"} EL2NSYNC = &Errno{"EL2NSYNC", 45, "Level 2 not synchronized"} EL3HLT = &Errno{"EL3HLT", 46, "Level 3 halted"} EL3RST = &Errno{"EL3RST", 47, "Level 3 reset"} ELNRNG = &Errno{"ELNRNG", 48, "Link number out of range"} EUNATCH = &Errno{"EUNATCH", 49, "Protocol driver not attached"} ENOCSI = &Errno{"ENOCSI", 50, "No CSI structure available"} EL2HLT = &Errno{"EL2HLT", 51, "Level 2 halted"} EBADE = &Errno{"EBADE", 52, "Invalid exchange"} EBADR = &Errno{"EBADR", 53, "Invalid request descriptor"} EXFULL = &Errno{"EXFULL", 54, "Exchange full"} ENOANO = &Errno{"ENOANO", 55, "No anode"} EBADRQC = &Errno{"EBADRQC", 56, "Invalid request code"} EBADSLT = &Errno{"EBADSLT", 57, "Invalid slot"} EBFONT = &Errno{"EBFONT", 59, "Bad font file format"} ENOSTR = &Errno{"ENOSTR", 60, "Device not a stream"} ENODATA = &Errno{"ENODATA", 61, "No data available"} ETIME = &Errno{"ETIME", 62, "Timer expired"} ENOSR = &Errno{"ENOSR", 63, "Out of streams resources"} ENONET = &Errno{"ENONET", 64, "Machine is not on the network"} ENOPKG = &Errno{"ENOPKG", 65, "Package not installed"} EREMOTE = &Errno{"EREMOTE", 66, "Object is remote"} ENOLINK = &Errno{"ENOLINK", 67, "Link has been severed"} EADV = &Errno{"EADV", 68, "Advertise error"} ESRMNT = &Errno{"ESRMNT", 69, "Srmount error"} ECOMM = &Errno{"ECOMM", 70, "Communication error on send"} EPROTO = &Errno{"EPROTO", 71, "Protocol error"} EMULTIHOP = &Errno{"EMULTIHOP", 72, "Multihop attempted"} EDOTDOT = &Errno{"EDOTDOT", 73, "RFS specific error"} EBADMSG = &Errno{"EBADMSG", 74, "Not a data message"} EOVERFLOW = &Errno{"EOVERFLOW", 75, "Value too large for defined data type"} ENOTUNIQ = &Errno{"ENOTUNIQ", 76, "Name not unique on network"} EBADFD = &Errno{"EBADFD", 77, "File descriptor in bad state"} EREMCHG = &Errno{"EREMCHG", 78, "Remote address changed"} ELIBACC = &Errno{"ELIBACC", 79, "Can not access a needed shared library"} ELIBBAD = &Errno{"ELIBBAD", 80, "Accessing a corrupted shared library"} ELIBSCN = &Errno{"ELIBSCN", 81, ".lib section in a.out corrupted"} ELIBMAX = &Errno{"ELIBMAX", 82, "Attempting to link in too many shared libraries"} ELIBEXEC = &Errno{"ELIBEXEC", 83, "Cannot exec a shared library directly"} EILSEQ = &Errno{"EILSEQ", 84, "Illegal byte sequence"} ERESTART = &Errno{"ERESTART", 85, "Interrupted system call should be restarted"} ESTRPIPE = &Errno{"ESTRPIPE", 86, "Streams pipe error"} EUSERS = &Errno{"EUSERS", 87, "Too many users"} ENOTSOCK = &Errno{"ENOTSOCK", 88, "Socket operation on non-socket"} EDESTADDRREQ = &Errno{"EDESTADDRREQ", 89, "Destination address required"} EMSGSIZE = &Errno{"EMSGSIZE", 90, "Message too long"} EPROTOTYPE = &Errno{"EPROTOTYPE", 91, "Protocol wrong type for socket"} ENOPROTOOPT = &Errno{"ENOPROTOOPT", 92, "Protocol not available"} EPROTONOSUPPORT = &Errno{"EPROTONOSUPPORT", 93, "Protocol not supported"} ESOCKTNOSUPPORT = &Errno{"ESOCKTNOSUPPORT", 94, "Socket type not supported"} EOPNOTSUPP = &Errno{"EOPNOTSUPP", 95, "Operation not supported on transport endpoint"} EPFNOSUPPORT = &Errno{"EPFNOSUPPORT", 96, "Protocol family not supported"} EAFNOSUPPORT = &Errno{"EAFNOSUPPORT", 97, "Address family not supported by protocol"} EADDRINUSE = &Errno{"EADDRINUSE", 98, "Address already in use"} EADDRNOTAVAIL = &Errno{"EADDRNOTAVAIL", 99, "Cannot assign requested address"} ENETDOWN = &Errno{"ENETDOWN", 100, "Network is down"} ENETUNREACH = &Errno{"ENETUNREACH", 101, "Network is unreachable"} ENETRESET = &Errno{"ENETRESET", 102, "Network dropped connection because of reset"} ECONNABORTED = &Errno{"ECONNABORTED", 103, "Software caused connection abort"} ECONNRESET = &Errno{"ECONNRESET", 104, "Connection reset by peer"} ENOBUFS = &Errno{"ENOBUFS", 105, "No buffer space available"} EISCONN = &Errno{"EISCONN", 106, "Transport endpoint is already connected"} ENOTCONN = &Errno{"ENOTCONN", 107, "Transport endpoint is not connected"} ESHUTDOWN = &Errno{"ESHUTDOWN", 108, "Cannot send after transport endpoint shutdown"} ETOOMANYREFS = &Errno{"ETOOMANYREFS", 109, "Too many references: cannot splice"} ETIMEDOUT = &Errno{"ETIMEDOUT", 110, "Connection timed out"} ECONNREFUSED = &Errno{"ECONNREFUSED", 111, "Connection refused"} EHOSTDOWN = &Errno{"EHOSTDOWN", 112, "Host is down"} EHOSTUNREACH = &Errno{"EHOSTUNREACH", 113, "No route to host"} EALREADY = &Errno{"EALREADY", 114, "Operation already in progress"} EINPROGRESS = &Errno{"EINPROGRESS", 115, "Operation now in progress"} ESTALE = &Errno{"ESTALE", 116, "Stale file handle"} EUCLEAN = &Errno{"EUCLEAN", 117, "Structure needs cleaning"} ENOTNAM = &Errno{"ENOTNAM", 118, "Not a XENIX named type file"} ENAVAIL = &Errno{"ENAVAIL", 119, "No XENIX semaphores available"} EISNAM = &Errno{"EISNAM", 120, "Is a named type file"} EREMOTEIO = &Errno{"EREMOTEIO", 121, "Remote I/O error"} EDQUOT = &Errno{"EDQUOT", 122, "Quota exceeded"} ENOMEDIUM = &Errno{"ENOMEDIUM", 123, "No medium found"} EMEDIUMTYPE = &Errno{"EMEDIUMTYPE", 124, "Wrong medium type"} ECANCELED = &Errno{"ECANCELED", 125, "Operation Canceled"} ENOKEY = &Errno{"ENOKEY", 126, "Required key not available"} EKEYEXPIRED = &Errno{"EKEYEXPIRED", 127, "Key has expired"} EKEYREVOKED = &Errno{"EKEYREVOKED", 128, "Key has been revoked"} EKEYREJECTED = &Errno{"EKEYREJECTED", 129, "Key was rejected by service"} EOWNERDEAD = &Errno{"EOWNERDEAD", 130, "Owner died"} ENOTRECOVERABLE = &Errno{"ENOTRECOVERABLE", 131, "State not recoverable"} ERFKILL = &Errno{"ERFKILL", 132, "Operation not possible due to RF-kill"} EHWPOISON = &Errno{"EHWPOISON", 133, "Memory page has hardware error"} EDEADLOCK = &Errno{"EDEADLOCK", 35, "Resource deadlock would occur"} // EDEADLK EWOULDBLOCK = &Errno{"EWOULDBLOCK", 11, "Operation would block"} // EAGAIN )
var ( F_RDLCK int16 = unix.F_RDLCK // Place a read lock on a file with FcntlFlock F_WRLCK int16 = unix.F_WRLCK // Place a write lock on a file with FcntlFlock F_UNLCK int16 = unix.F_UNLCK // Release the lock on a file with FcntlFlock )
var ( F_SETLK = unix.F_SETLK // Acquire or release a lock F_SETLKW = unix.F_SETLKW // As for F_SETLK, but if a conflicting lock is held on the file, then wait for that lock to be released F_GETLK = unix.F_GETLK // Return details about the current lock )
var ( ErrEmpty = errors.New("empty") ErrInvalidPid = errors.New("invalid pid") )
var (
ErrAssert = errors.New("syscall.Stat_t assertion failed")
)
var (
ErrUserNotFound = errors.New("user not found")
)
var Errnos = []Errno{}/* 133 elements not displayed */
Errno table
var (
ShredIterations = 3 // Default iteration number for Shred()
)
Functions ¶
func ErrnoFromSyscallErrno ¶
ErrnoFromSyscallErrno converts a syscall.Errno to *Errno.
If err is not a valid syscall.Errno, returns the err as is. If err is syscall.Errno, but not with a valid number, returns the number as an error string.
func FcntlCheckfl ¶
FcntlCheckfl returns whether the flag is set for fd.
func FcntlGetfl ¶
FcntlGetfl returns the file access mode and the file status flags.
func FileContains ¶
FileContains reports whether substr is in path file. A line in the file does not contains the newline character ("\n"). This function uses bufio.Scanner to able to handle large files.
func FileContainsLine ¶
FileContainsLine reports whether line is in path file. A line in the file does not contains the newline character ("\n"). This function uses bufio.Scanner to able to handle large files.
func FileCountLines ¶
FileCountLines returns the number lines in file.
func FileModeIsBlk ¶
FileModeIsBlk returns whether the file is a block special file (a device like a disk).
func FileModeIsChr ¶
FileModeIsChr returns whether the file is a character special file (a device like a terminal).
func FileModeIsFifo ¶
FileModeIsFifo returns whether the file is a FIFO special file, or a pipe.
func FileModeIsLnk ¶
FileModeIsLnk returns whether the file is a symbolic link.
func FileModeIsReg ¶
FileModeIsReg returns whether the file is a regular file.
func FileModeIsSet ¶
FileModeIsSet check whether m bit is set in mode.
func FileModeIsSetPath ¶
FileModeIsSetPath returns whether mode m of file is set in path. This function does not follow symbolic link.
func FileModeIsSock ¶
FileModeIsSock returns whether the file is a socket.
func FileModeSetPath ¶
FileModeSetPath sets the mode bit m for file in path.
func FileModeUnsetPath ¶
FileModeUnsetPath unsets the mode bit m for file in path.
func FlockGetRead ¶
FlockGetRead returns whether read lock (F_RDLCK) could be placed on fd. Every byte will be checked for lock.
func FlockGetWrite ¶
FlockGetRead returns whether write lock (F_WRLCK) could be placed on fd. Every byte will be checked for lock.
func FlockSetRead ¶
FlockSetRead acquire the advisory record lock for read on fd. This function returns error if a conflicting lock is held by another process. In order to place a read lock, fd must be open for reading.
func FlockSetReadWait ¶
FlockSetReadWait acquire the advisory record lock for read on fd. If a conflicting lock is held on the file, then wait for that lock to be released. In order to place a read lock, fd must be open for reading.
func FlockSetWrite ¶
FlockSetWrite acquire the advisory record lock for write on fd. This function returns error if a conflicting lock is held by another process. In order to place a write lock, fd must be open for writing.
func FlockSetWriteWait ¶
FlockSetWriteWait acquire the advisory record lock for write on fd. If a conflicting lock is held on the file, then wait for that lock to be released. In order to place a write lock, fd must be open for writing.
func FlockUnlock ¶
FlockUnlock release the advisory record lock on fd. This function returns error if a conflicting lock is held by another process.
func FlockUnlockWait ¶
FlockUnlockWait release the advisory record lock on fd. If a conflicting lock is held on the file, then wait for that lock to be released.
func GetFileGroup
deprecated
func GetFileOwner
deprecated
func IsBlkPath ¶
IsBlkPath returns whether the file in path is a block special file (a device like a disk).
func IsChrPath ¶
IsChrPath returns whether the file in path is a character special file (a device like a terminal).
func IsFifoPath ¶
IsFifoPath returns whether the file in path is a FIFO special file, or a pipe.
func IsPathExists ¶
IsPathExists returns whether path is exists. If path is a symbolic link, it is dereferenced.
func IsSockPath ¶
IsSockPath returns whether the file in path is a socket.
func NewErrno ¶
NewErrno returns a new *Errno from code n. If n is not a valid errno, returns n as a string.
This function allocates a new struct.
func PIDCheck ¶
CheckPath returns true if the stored PID in path is running. Remove the newline character ('\n') from the content if exist.
Returns ErrEmpty if lock file is empty. Returns ErrInvalidPid if the content is an invalid (eg.: not a number).
func PIDCreate ¶
PIDCreate creates the pid file in path with mode perm (before umask). The file in path should not exist.
func PIDRead ¶
PIDRead returns the stored pid in path. Remove the newline character ('\n') from the content if exist.
Returns -1 if error occurred. Returns ErrEmpty if file is empty. Returns ErrInvalidPid if the content is an invalid (eg.: not a number).
func Shred ¶
Shred overwrites file in path for n times. Writes random data if random is true, else zeroes.
func ShredLock ¶
ShredLock apply a nonblocking write lock with FlockWrite and overwrites file in path for n times. Writes random data if random is true, else zeroes.
This function returns error if other lock is applied on path.
func ShredLockWait ¶
ShredLock apply a blocking write lock with FlockWriteWait and overwrites file in path for n times. Writes random data if random is true, else zeroes.
This function blocks until other lock is applied on path.
func Truncate ¶
Truncate overwrites the file with shred for ShredIterations times and truncates to 0.
func TruncatePath ¶
TruncatePath overwrites the file at path with shred for ShredIterations times and truncates to 0.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
type FileInfo ¶
type FileInfo struct { Dev uint64 // ID of device containing file Ino uint64 // Inode number Mode FileMode // File type and mode Nlink uint64 // Number of hard links User user.User // Owner user. If invalid uid found (that can happen), only the Uid field is set. Group user.Group // Owner group. If invalid gid found (that can happen), only the Gid field is set. Rdev uint64 // Device ID (if special file) Size int64 // Total size, in bytes Blksize int64 // Block size for filesystem I/O Blocks int64 // Number of 512 B blocks allocated Atim time.Time // Time of last access Mtim time.Time // Time of last modification Ctim time.Time // Time of last status change }
FileInfo describes information about a file. See struct stat at stat(3) manual for more info.
func Lstat ¶
Lstat returns information about a file specified by path. If path is a symbolic link, then it returns information about the link itself, not the file that the link refers to.
No permissions are required on the file itself, execute (search) permission is required on all of the directories in pathname that lead to the file. See stat(2) manual for more info.
type FileMode ¶
type FileMode uint32
const ( S_IFMT FileMode = 00170000 // This is a bit mask used to extract the file type code from a mode value. S_IFSOCK FileMode = 0140000 // This is the file type constant of a socket. S_IFLNK FileMode = 0120000 // This is the file type constant of a symbolic link. S_IFREG FileMode = 0100000 // This is the file type constant of a regular file. S_IFBLK FileMode = 0060000 // This is the file type constant of a block-oriented device file. S_IFDIR FileMode = 0040000 // This is the file type constant of a directory file. S_IFCHR FileMode = 0020000 // This is the file type constant of a character-oriented device file. S_IFIFO FileMode = 0010000 // This is the file type constant of a FIFO or pipe. S_ISUID FileMode = 0004000 // This is the set-user-ID on execute bit. S_ISGID FileMode = 0002000 // This is the set-group-ID on execute bit. S_ISVTX FileMode = 0001000 // This is the sticky bit. S_IRWXU FileMode = 0000700 // This is equivalent to (S_IRUSR | S_IWUSR | S_IXUSR). S_IRUSR FileMode = 00000400 // Read permission bit for the owner of the file. S_IWUSR FileMode = 00000200 // Write permission bit for the owner of the file. S_IXUSR FileMode = 00000100 // Execute (for ordinary files) or search (for directories) permission bit for the owner of the file. S_IRWXG FileMode = 00000070 // This is equivalent to (S_IRGRP | S_IWGRP | S_IXGRP). S_IRGRP FileMode = 00000040 // Read permission bit for the group owner of the file. S_IWGRP FileMode = 00000020 // Write permission bit for the group owner of the file. S_IXGRP FileMode = 00000010 // Execute or search permission bit for the group owner of the file. S_IRWXO FileMode = 00000007 // This is equivalent to (S_IROTH | S_IWOTH | S_IXOTH). S_IROTH FileMode = 00000004 // Read permission bit for other users. S_IWOTH FileMode = 00000002 // Write permission bit for other users. S_IXOTH FileMode = 00000001 // Execute or search permission bit for other users. )
func FileModeClear ¶
FileModeClear clears m bit in mode.
func FileModeGetPath ¶
FileModeGetPath returns the mode of the file in path. This function (and every *Path functions) does not follows symbolic link.
func FileModeToggle ¶
FileModeClear clears m bit in mode.
type User ¶
type User struct { Username string // Login name Password string // Optional encrypted password UID int // Numerical user ID GID int // Numerical group ID Gecos string // User name or comment field Home string // User home directory Shell string // Optional user command interpreter }
Passwd stores the user account information.
See passwd(5) for more info.
func LookupUser ¶
LookupUser search for user with username username. If the user cannot be found, returns ErrUserNotFound.
This function parses the "/etc/passwd" file.
func LookupUserID ¶
LookupUserID search for user with ID uid. If the user cannot be found, returns ErrUserNotFound.
This function parses the "/etc/passwd" file.