Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
Data Structures | Macros | Functions
stat.h File Reference
#include <sys/types.h>
#include <time.h>
Include dependency graph for stat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  stat
 

Macros

#define S_IFMT   0170000 /* Mask for the file type */
 
#define S_IFIFO   0010000 /* FIFO */
 
#define S_IFCHR   0020000 /* Character device */
 
#define S_IFDIR   0040000 /* Directory */
 
#define S_IFBLK   0060000 /* Block device */
 
#define S_IFREG   0100000 /* Regular file */
 
#define S_IFLNK   0120000 /* Symbolic link */
 
#define S_IFSOCK   0140000 /* Socket */
 
#define S_ISFIFO(m)   (((m) &S_IFMT) == S_IFIFO)
 
#define S_ISCHR(m)   (((m) &S_IFMT) == S_IFCHR)
 
#define S_ISDIR(m)   (((m) &S_IFMT) == S_IFDIR)
 
#define S_ISBLK(m)   (((m) &S_IFMT) == S_IFBLK)
 
#define S_ISREG(m)   (((m) &S_IFMT) == S_IFREG)
 
#define S_ISLNK(m)   (((m) &S_IFMT) == S_IFLNK)
 
#define S_ISSOCK(m)   (((m) &S_IFMT) == S_IFSOCK)
 
#define S_ISUID   0004000
 
#define S_ISGID   0002000
 
#define S_ISVTX   0001000
 
#define S_IRWXU   0000700
 
#define S_IRUSR   0000400
 
#define S_IWUSR   0000200
 
#define S_IXUSR   0000100
 
#define S_IRWXG   0000070
 
#define S_IRGRP   0000040
 
#define S_IWGRP   0000020
 
#define S_IXGRP   0000010
 
#define S_IRWXO   0000007
 
#define S_IROTH   0000004
 
#define S_IWOTH   0000002
 
#define S_IXOTH   0000001
 
#define st_atime   st_atim.tv_sec
 
#define st_mtime   st_mtim.tv_sec
 
#define st_ctime   st_ctim.tv_sec
 
#define UTIME_TO_NOW   ((uint32_t) -1)
 
#define UTIME_NOW   ((1l << 30) - 1l)
 
#define UTIME_OMIT   ((1l << 30) - 2l)
 

Functions

int fstat (int fd, struct stat *statbuf)
 Return information about a file, in the buffer pointed to by statbuf. More...
 
int mknod (const char *pathname, mode_t mode, dev_t dev)
 Create a filesystem node (file, device special file, or named pipe) named pathname, with attributes specified by mode and dev. More...
 
int mkfifo (const char *pathname, mode_t mode)
 Makes a FIFO special file with name pathname. More...
 
int mkdir (const char *pathname, mode_t mode)
 Create a directory named pathname. More...
 
mode_t umask (mode_t mask)
 Set the permission bits withheld from the files the task creates. More...
 
int utime (const char *pathname, uint32_t mtime)
 Replace the time the contents of a file were last written. More...
 
int chmod (const char *pathname, mode_t mode)
 Replace the permission bits of a file. More...
 
int stat (const char *pathname, struct stat *statbuf)
 Return information about the file specified by the pathname, in the buffer pointed to by statbuf. More...
 
int lstat (const char *pathname, struct stat *statbuf)
 Return information about the file specified by the pathname, the way stat() does. Tenok gives a file one name, so there is no link for the call to stop at and the two report the same thing. More...
 
int futimens (int fd, const struct timespec times[2])
 Stamp the file a descriptor is open on with the times given. Tenok keeps no way back from a descriptor to the file it was opened on, which is what the call would need. More...
 

Function Documentation

◆ chmod()

int chmod ( const char *  pathname,
mode_t  mode 
)

Replace the permission bits of a file.

Parameters
pathnameThe pathname of the file.
modeThe permission bits to give the file.
Return values
int0 on success and -1 on error, with the reason in errno.

◆ fstat()

int fstat ( int  fd,
struct stat statbuf 
)

Return information about a file, in the buffer pointed to by statbuf.

Parameters
fdThe file descriptor to provide.
Return values
int0 on success and nonzero error number on error.

◆ futimens()

int futimens ( int  fd,
const struct timespec  times[2] 
)

Stamp the file a descriptor is open on with the times given. Tenok keeps no way back from a descriptor to the file it was opened on, which is what the call would need.

Parameters
fdThe descriptor.
timesThe times to stamp it with.
Return values
int-1 with errno set to ENOSYS.

◆ lstat()

int lstat ( const char *  pathname,
struct stat statbuf 
)

Return information about the file specified by the pathname, the way stat() does. Tenok gives a file one name, so there is no link for the call to stop at and the two report the same thing.

Parameters
pathnameThe pathname of the file.
statbufThe buffer for returning the file information.
Return values
int0 on success and nonzero error number on error.

◆ mkdir()

int mkdir ( const char *  pathname,
mode_t  mode 
)

Create a directory named pathname.

Parameters
pathnameThe pathname of the directory to create.
modeThe permission bits of the new directory.
Return values
int0 on success and nonzero error number on error.

◆ mkfifo()

int mkfifo ( const char *  pathname,
mode_t  mode 
)

Makes a FIFO special file with name pathname.

Parameters
pathnameThe path name to create the new fifo file.
modeThe permission bits of the new file.
Return values
int0 on success and nonzero error number on error.

◆ mknod()

int mknod ( const char *  pathname,
mode_t  mode,
dev_t  dev 
)

Create a filesystem node (file, device special file, or named pipe) named pathname, with attributes specified by mode and dev.

Parameters
pathnameThe pathname to create the new file.
modeThe file type and the permission bits of the new file.
devThe device number, when the file is a device. Not used.
Return values
int0 on success and nonzero error number on error.

◆ stat()

int stat ( const char *  pathname,
struct stat statbuf 
)

Return information about the file specified by the pathname, in the buffer pointed to by statbuf.

Parameters
pathnameThe pathname of the file.
statbufThe buffer for returning the file information.
Return values
int0 on success and nonzero error number on error.

◆ umask()

mode_t umask ( mode_t  mask)

Set the permission bits withheld from the files the task creates.

Parameters
maskThe bits to withhold from now on.
Return values
mode_tThe mask that was in effect before the call.

◆ utime()

int utime ( const char *  pathname,
uint32_t  mtime 
)

Replace the time the contents of a file were last written.

Parameters
pathnameThe pathname of the file.
mtimeSeconds since the epoch, or UTIME_TO_NOW for the present.
Return values
int0 on success and -1 on error, with the reason left in errno.