| Index | Manual | Download | Source | Macros | Embedded word Case ins.
Sitemap | Links | Forum | Tests | Projects

# linsfile.htm
Structures
DIRENT
DIRENT64
NEWSTAT
STAT
STAT32
STAT64
Symbols
Constants

This file can be included to program for Linux written in EuroAssembler.

It declares the most often used constant symbols and structures for
file functions derived from Linux header files in `/usr/include/` directory.

    linsfile HEAD

↑ DIRENT
  Directory entry read by `LinAPI getdents, fd, DirEntPtr, DirEntSize` . The structure has variable size.
Documented
  manpages.ubuntu.com/manpages/cosmic/man2/getdents.2.html

    DIRENT STRUC
    .d_ino    D DWORD ; Inode number.
    .d_off    D DWORD ; Offset to the next DIRENT.
    .d_reclen D WORD  ; Size of this DIRENT structure.
    .d_name   D NAME_MAX * BYTE ; Zero-terminated file name, variable DWORD aligned size.
    .d_type   D B     ; File type.
           ENDSTRUC DIRENT ; SIZE# DIRENT = 271

↑ DIRENT64
  Directory entry read by `LinABI getdents64, fd, DirEntPtr, DirEntSize` . The structure has variable size.
Documented
  manpages.ubuntu.com/manpages/cosmic/man2/getdents.2.html

    DIRENT64 STRUC
    .d_ino    D QWORD ; Inode number.
    .d_off    D QWORD ; Offset to the next DIRENT64.
    .d_reclen D WORD  ; Size of this DIRENT64 structure.
    .d_type   D B     ; File type.
    .d_name   D NAME_MAX * BYTE ; Zero-terminated file name, variable QWORD aligned size.
           ENDSTRUC DIRENT64  ; SIZE# DIRENT64 = 279

↑ STAT
  File information read in 64bit mode by `LinABI stat|lstat|fstat`.
Documented
  https://linux.die.net/man/2/stat64, http://man7.org/linux/man-pages/man2/stat.2.html

    STAT      STRUC
    .st_dev     D QWORD ; ID of device containing file.
    .st_ino     D QWORD ; Inode number.
    .st_nlink   D QWORD ; Number of hard links.
    .st_mode    D DWORD ; File type and mode.
    .st_uid     D DWORD ; User ID of owner.
    .st_gid     D DWORD ; Group ID of owner.
                D DWORD
    .st_rdev    D QWORD ; Device ID (if special file).
    .st_size    D QWORD ; Total size, in bytes.
    .st_blksize D QWORD ; Block size for filesystem I/O (often 4KB).
    .st_blocks  D QWORD ; Number of 512B blocks allocated.
    .st_atime   D OWORD ; Time of last access.
    .st_mtime   D OWORD ; Time of last modification.
    .st_ctime   D OWORD ; Time of last status change.
                D 3*QWORD
              ENDSTRUC STAT ; SIZE# STAT = 144

↑ STAT32
  File information read in 32bit mode by `LinAPI stat|lstat|fstat`.
Remark
  If 32bit kernel function stat|fstat|lstat is called on 64bit Linux, it may fail with EOVERFLOW when st_ino doesn't fit to DWORD. It is better to use `LinAPI stat64|lstat64|fstat64` which returns STAT64.
Documented
  manpages.ubuntu.com/manpages/cosmic/man2/stat.2.html

    STAT32 STRUC
    .st_dev         D DWORD ; ID of device containing file.
    .st_ino         D DWORD ; Inode number.
    .st_mode        D  WORD ; File type and mode.
    .st_nlink       D  WORD ; Number of hard links.
    .st_uid         D  WORD ; User ID of owner.
    .st_gid         D  WORD ; Group ID of owner.
    .st_rdev        D DWORD ; Device ID (if special file).
    .st_size        D DWORD ; Total size, in bytes.
    .st_blksize     D DWORD ; Block size for filesystem I/O.
    .st_blocks      D DWORD ; Number of 512B blocks allocated.
    .st_atime       D DWORD ; Time of last access.
    .st_mtime       D DWORD ; Time of last modification.
    .st_ctime       D DWORD ; Time of last status change.
           ENDSTRUC STAT32  ; SIZE# STAT32 = 44

↑ NEWSTAT
  File information read in 32bit mode by `LinAPI newstat|newlstat|newfstat`.

    NEWSTAT STRUC
    .st_dev         D DWORD ; ID of device containing file.
    .st_ino         D DWORD ; Inode number.
    .st_mode        D  WORD ; File type and mode.
    .st_nlink       D  WORD ; Number of hard links.
    .st_uid         D  WORD ; User ID of owner.
    .st_gid         D  WORD ; Group ID of owner.
    .st_rdev        D DWORD ; Device ID (if special file).
    .st_size        D DWORD ; Total size, in bytes.
    .st_blksize     D DWORD ; Block size for filesystem I/O.
    .st_blocks      D DWORD ; Number of 512B blocks allocated.
    .st_atime       D QWORD ; Time of last access.
    .st_mtime       D QWORD ; Time of last modification.
    .st_ctime       D QWORD ; Time of last status change.
                    D QWORD
           ENDSTRUC NEWSTAT ; SIZE# NEWSTAT = 64

↑ STAT64
  File information read in 32bit mode by `LinAPI stat64|lstat64|fstat64`.
Documented
  https://linux.die.net/man/2/stat64, http://man7.org/linux/man-pages/man2/stat.2.html

    STAT64    STRUC
    .st_dev     D QWORD ; ID of device containing file.
                D DWORD
    .st_ino     D DWORD ; Inode number.
    .st_mode    D DWORD ; File type and mode.
    .st_nlink   D DWORD ; Number of hard links.
    .st_uid     D DWORD ; User ID of owner.
    .st_gid     D DWORD ; Group ID of owner.
    .st_rdev    D QWORD ; Device ID (if special file).
                D DWORD
    .st_size    D QWORD ; Total size, in bytes.
    .st_blksize D DWORD ; Block size for filesystem I/O (often 4KB).
    .st_blocks  D QWORD ; Number of 512B blocks allocated.
    .st_atime   D QWORD ; Time of last access.
    .st_mtime   D QWORD ; Time of last modification.
    .st_ctime   D QWORD ; Time of last status change.
                D QWORD
              ENDSTRUC STAT64 ; SIZE# STAT64 = 96

↑ Constants
  Encoding of constant symbols used in LinAPI.
Documented
  `/usr/include/*.h`, , manpages.ubuntu.com/manpages/cosmic/man7/inode.7.html.

    ; Standard file descriptors.
    STDIN_FILENO        = 0    ; Standard input.
    STDOUT_FILENO       = 1    ; Standard output.
    STDERR_FILENO       = 2    ; Standard error output.
    NAME_MAX            = 260  ; Maximal possible filename size (used in Linux).
    MAX_PATH_SIZE       = 260  ; Maximal possible filename size (used in Windows).

    ; stat.st_mode
    S_IFSOCK =  0140000q  ; socket
    S_IFLNK  =  0120000q  ; symbolic link
    S_IFREG  =  0100000q  ; regular file
    S_IFBLK  =  0060000q  ; block device
    S_IFDIR  =  0040000q  ; directory
    S_IFCHR  =  0020000q  ; character device
    S_IFIFO  =  0010000q  ; FIFO
    S_ISUID  =    04000q  ; set-user-ID bit (see execve(2))
    S_ISGID  =    02000q  ; set-group-ID bit (see below)
    S_ISVTX  =    01000q  ; sticky bit (see below)
    S_IRWXU  =    00700q  ; owner has read, write, and execute permission
    S_IRUSR  =    00400q  ; owner has read permission
    S_IWUSR  =    00200q  ; owner has write permission
    S_IXUSR  =    00100q  ; owner has execute permission
    S_IRWXG  =    00070q  ; group has read, write, and execute permission
    S_IRGRP  =    00040q  ; group has read permission
    S_IWGRP  =    00020q  ; group has write permission
    S_IXGRP  =    00010q  ; group has execute permission
    S_IRWXO  =    00007q  ; others (not in group) have read, write and execute permission
    S_IROTH  =    00004q  ; others have read permission
    S_IWOTH  =    00002q  ; others have write permission
    S_IXOTH  =    00001q  ; others have execute permission

    ; Flags in sys_fstatat.
    AT_FDCWD            = -100 ; Use current directory.
    AT_SYMLINK_NOFOLLOW = 0x100; Do not follow symbolic links.
    AT_REMOVEDIR        = 0x200; Remove directory instead of unlinking file.
    AT_SYMLINK_FOLLOW   = 0x400; Follow symbolic links.
    AT_NO_AUTOMOUNT	    = 0x800; Suppress terminal automount traversal.

    R_OK           = 4         ; Test for read permission.
    W_OK           = 2         ; Test for write permission.
    X_OK           = 1         ; Test for execute permission.
    F_OK           = 0         ; Test for existence.
    O_RDONLY       = 00000000q ; Create file as read-only.
    O_WRONLY       = 00000001q ; Create file as write-only.
    O_RDWR         = 00000002q ; Create file as read|write.
    O_ACCMODE      = 00000003q
    O_CREAT        = 00000100q ; Not fcntl.
    O_EXCL         = 00000200q ; Not fcntl.
    O_NOCTTY       = 00000400q ; Not fcntl.
    O_TRUNC        = 00001000q ; Not fcntl.
    O_APPEND       = 00002000q
    O_NONBLOCK     = 00004000q
    O_DSYNC        = 00010000q ; Used to be O_SYNC, see below.
    FASYNC         = 00020000q ; Fcntl, for BSD compatibility.
    O_DIRECT       = 00040000q ; Direct disk access hint.
    O_LARGEFILE    = 00100000q
    O_DIRECTORY    = 00200000q ; Must be a directory.
    O_NOFOLLOW     = 00400000q ; Don't follow links.
    O_NOATIME      = 01000000q
    O_CLOEXEC      = 02000000q ; Set close_on_exec.
    O_PATH         = 10000000q

    ; Values for the WHENCE argument to lseek.
    SEEK_SET       =  0 ; Seek from beginning of file.
    SEEK_CUR       =  1 ; Seek from current position.
    SEEK_END       =  2 ; Seek from end of file.
    SEEK_DATA      =  3 ; Seek to next data.
    SEEK_HOLE      =  4 ; Seek to next hole.
    SEEK_MAX       = SEEK_HOLE
    F_GETLK        =  5 ; Get record locking info.
    F_SETLK        =  6 ; Set record locking info (non-blocking).
    F_SETLKW       =  7 ; Set record locking info (blocking).
    F_GETLK64      = 12 ; Get record locking info.
    F_SETLK64      = 13 ; Set record locking info (non-blocking).
    F_SETLKW64     = 14 ; Set record locking info (blocking).

    ; These are the fs-independent mount-flags: up to 32 flags are supported

    MS_RDONLY       = 1       ; Mount read-only.
    MS_NOSUID       = 2       ; Ignore suid and sgid bits.
    MS_NODEV        = 4       ; Disallow access to device special files.
    MS_NOEXEC       = 8       ; Disallow program execution.
    MS_SYNCHRONOUS  = 16      ; Writes are synced at once.
    MS_REMOUNT      = 32      ; Alter flags of a mounted FS.
    MS_MANDLOCK     = 64      ; Allow mandatory locks on an FS.
    MS_DIRSYNC      = 128     ; Directory modifications are synchronous.
    MS_NOATIME      = 1024    ; Do not update access times.
    MS_NODIRATIME   = 2048    ; Do not update directory access times.
    MS_BIND         = 4096
    MS_MOVE         = 8192
    MS_REC          = 16384
    MS_VERBOSE      = 32768   ;   MS_VERBOSE is deprecated.
    MS_POSIXACL     = (1<<16) ; > VFS does not apply the umask.
    MS_UNBINDABLE   = (1<<17) ; > Change to unbindable.
    MS_PRIVATE      = (1<<18) ; > Change to private.
    MS_SLAVE        = (1<<19) ; > Change to slave.
    MS_SHARED       = (1<<20) ; > Change to shared.
    MS_RELATIME     = (1<<21) ; > Update atime relative to mtime/ctime.
    MS_KERNMOUNT    = (1<<22) ; > This is a kern_mount call.
    MS_I_VERSION    = (1<<23) ; > Update inode I_version field.
    MS_STRICTATIME  = (1<<24) ; > Always perform atime updates.

    ; Memory-map protection
    MAP_SHARED      = 0x00000001 ; Share changes.
    MAP_PRIVATE     = 0x00000002 ; Changes are private.
    MAP_FIXED       = 0x00000010 ; Interpret addr exactly.
    MAP_ANONYMOUS   = 0x00000020 ; Don't use a file.
    MAP_32BITS      = 0x00000040 ; Only give out 32bit addresses.
    MAP_GROWSDOWN   = 0x00000100 ; Stack-like segment.
    MAP_DENYWRITE   = 0x00000800 ; ETXTBSY.
    MAP_EXECUTABLE  = 0x00001000 ; Mark it as executable.
    MAP_LOCKED      = 0x00002000 ; Lock the mapping.
    MAP_NORESERVE   = 0x00004000 ; Do not check for reservations.
    MAP_POPULATE    = 0x00008000 ; Populate (prefault) pagetables.
    MAP_NONBLOCK    = 0x00010000 ; Do not block on IO.
    MAP_STACK       = 0x00020000 ; Allocation is for a stack.
    MAP_HUGETLB     = 0x00040000 ; Create huge mapping.
    MAP_SYNC        = 0x00080000 ; Perform synchronous page faults for the mapping.
    MAP_FIXED_NOREPLACE = 0x00100000 ; MAP_FIXED but do not unmap underlying mapping.

    PROT_NONE       = 0x0     ; Page can not be accessed.
    PROT_READ       = 0x1     ; Page can be read.
    PROT_WRITE      = 0x2     ; Page can be written.
    PROT_EXEC       = 0x4     ; Page can be executed.

    ; DIRENT64.d_type values.
    DT_UNKNOWN      =  0      ; The file type is unknown.
    DT_FIFO         =  1      ; This is a named pipe, or FIFO.
    DT_CHR          =  2      ; This is a character device.
    DT_DIR          =  4      ; This is a directory.
    DT_BLK          =  6      ; This is a block device.
    DT_REG          =  8      ; This is a regular file.
    DT_LNK          = 10      ; This is a symbolic link.
    DT_SOCK         = 12      ; This is a UNIX domain socket.
    DT_WHT          = 14

     ENDHEAD linsfile

▲Back to the top▲