Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • K kernel
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 13
    • Issues 13
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • erlends-os
  • kernel
  • kernel
  • Wiki
    • Abi
  • stat

stat · Changes

Page history
Add more pages. authored Oct 10, 2019 by Erlend Sveen's avatar Erlend Sveen
Hide whitespace changes
Inline Side-by-side
abi/stat.md 0 → 100644
View page @ ef555113
Get the metadata/statistics for a file, directory or other file system item.
### Syntax ###
```cpp
#include <sys/stat.h>
int fstat (const char *filename, struct stat *st);
```
### Parameters ###
* `filename`
Path to the file to retrieve the `stat` structure for.
* `st`
Pointer to a `stat` structure that will receive the information.
### Return Value ###
The return value is null if successful. Otherwise, the return value is negative
and errno is set:
* **ENOENT**
No such file or directory.
* **ENOSYS**
The system call is not supported for this file system, or not implemented.
### Remarks ###
The `stat` structure is as follows:
```cpp
struct stat
{
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
blksize_t st_blksize;
blkcnt_t st_blocks;
};
```
Note that, being a microcontroller OS, most fields are left blank. The fields
that will contain usable information are:
* `st_mode`
Bitfield that may be accessed by the macros in the header file. The first
part describes the type of file, and may be one of the following:
* `S_IFBLK`: Block device. Typically disk drives.
* `S_IFCHR`: Char device. Typically device drivers.
* `S_IFIFO`: FIFO (pipe in our terminology).
* `S_IFREG`: Regular file.
* `S_IFDIR`: Directory.
* `S_IFLNK`: Link.
* `S_IFSOCK`: Network socket.
The bitfield also contains the access rights of the file (read/write/exec
permissions). The following definitions define the bits that are used:
* `S_IRUSR`: Owner user read access.
* `S_IWUSR`: Owner user write access.
* `S_IXUSR`: Owner user execute access.
* `S_IRWXU`: Bitwise or of the above three.
* `S_IRGRP`: Group read access.
* `S_IWGRP`: Group write access.
* `S_IXGRP`: Group execute access.
* `S_IRWXG`: Bitwise or of the above three.
* `S_IROTH`: Anyone read access.
* `S_IWOTH`: Anyone write access.
* `S_IXOTH`: Anyone execute access.
* `S_IRWXO`: Bitwise or of the above three.
**Note:** At the time of writing, only the KFS care about the access rights.
You may show the access rights of a file or directory contents with the
`ls -l` command.
* `st_size`
The size of the object in bytes. PipeFS will return the buffer size
available to the pipe. Other special file systems may return a fixed size,
depending on the characteristics of that file system.
Clone repository
  • abi
    • bind
    • chdir
    • close
    • closedir
    • dup2
    • exit
    • fstat
    • getcwd
    • getpgrp
    • getpid
    • gettimeofday
    • ioctl_fcntl
    • kill
    • link
    • lseek
View All Pages