Systemy operacyjne
Published on 19.10.2026 at 13:30
Last updated on 19.10.2026 at 15:53
Jak czytać
Krótki spis (cheatsheet)
Każdy znaczek "" jest linkiem do strony manuala (man page) z którego pochodzi definicja, nadana przez Arch Linux.
Każdy link otwiera się w nowej karcie.
Szczegółowe informacje są w linkach, ale niektóre treści można rozszerzyć:
Wszystko w code block jest z manuala.
Struktury
ino_t d_ino File serial number.
char d_name[] Filename string of entry.DIR
A type representing a directory stream. The DIR type may be an incomplete type.#include <sys/stat.h>
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* Inode number */
mode_t st_mode; /* File type and mode */
nlink_t st_nlink; /* Number of hard links */
uid_t st_uid; /* User ID of owner */
gid_t st_gid; /* Group ID of owner */
dev_t st_rdev; /* Device ID (if special file) */
off_t st_size; /* Total size, in bytes */
blksize_t st_blksize; /* Block size for filesystem I/O */
blkcnt_t st_blocks; /* Number of 512 B blocks allocated */
/* Since POSIX.1-2008, this structure supports nanosecond
precision for the following timestamp fields.
For the details before POSIX.1-2008, see HISTORY. */
struct timespec st_atim; /* Time of last access */
struct timespec st_mtim; /* Time of last modification */
struct timespec st_ctim; /* Time of last status change */
#define st_atime st_atim.tv_sec /* Backward compatibility */
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
};void *iov_base Base address of a memory region for input or output.
size_t iov_len The size of the memory pointed to by iov_base.int fd The following descriptor being polled.
short events The input event flags (see below).
short revents The output event flags (see below).Funkcje
Katalogi
#include <dirent.h>
struct dirent *readdir(DIR *dirp);#include <dirent.h>
DIR *fdopendir(int fd);
DIR *opendir(const char *dirname);The fdopendir() function shall be equivalent to the opendir() function except that the directory is specified by a file descriptor rather than by a name.#include <dirent.h>
int closedir(DIR *dirp);#include <unistd.h>
int chdir(const char *path);#include <unistd.h>
char *getcwd(char *buf, size_t size);#include <sys/stat.h>
int mkdir(const char *path, mode_t mode);Pliki
#include <stdio.h>
FILE *fopen(const char *restrict pathname, const char *restrict mode);#include <stdio.h>
int fseek(FILE *stream, long offset, int whence);#include <stdio.h>
int fclose(FILE *stream);#include <stdio.h>
int fprintf(FILE *restrict stream, const char *restrict format, ...);#include <stdio.h>
int fputc(int c, FILE *stream);#include <stdio.h>
int fputs(const char *restrict s, FILE *restrict stream);#include <stdio.h>
size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
FILE *restrict stream);#include <stdio.h>
int fscanf(FILE *restrict stream, const char *restrict format, ...);#include <stdio.h>
int fgetc(FILE *stream);#include <stdio.h>
char *fgets(char *restrict s, int n, FILE *restrict stream);#include <stdio.h>
size_t fread(void *restrict ptr, size_t size, size_t nitems,
FILE *restrict stream);#include <unistd.h>
int link(const char *path1, const char *path2);#include <unistd.h>
ssize_t readlink(const char *restrict path, char *restrict buf,
size_t bufsize);#include <fcntl.h>
int open(const char *path, int oflags, ...);#include <unistd.h>
int close(int fildes);#include <unistd.h>
ssize_t read(int fildes, void *buf, size_t nbyte);#include <unistd.h>
ssize_t write(int fildes, const void *buf, size_t nbyte);#include <unistd.h>
off_t lseek(int fildes, off_t offset, int whence);#include <sys/uio.h>
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt);#include <sys/uio.h>
ssize_t readv(int fildes, const struct iovec *iov, int iovcnt);#include <sys/mman.h>
void *mmap(void *addr, size_t len, int prot, int flags,
int fildes, off_t off);#include <fcntl.h>
int fcntl(int fildes, int cmd, ...);#include <poll.h>
int poll(struct pollfd fds[], nfds_t nfds, int timeout);#include <unistd.h>
int symlink(const char *path1, const char *path2);Pozostałe (Miscellaneous)
#include <fcntl.h>
#include <sys/stat.h>
int lstat(const char *restrict path, struct stat *restrict buf);
int stat(const char *restrict path, struct stat *restrict buf);The lstat() function shall be equivalent to stat(), except when path refers to a symbolic link. In that case lstat() shall return information about the link, while stat() shall return information about the file the link references.#include <sys/stat.h>
int chmod(const char *path, mode_t mode);#include <unistd.h>
int access(const char *path, int amode);#include <stdlib.h>
int rand(void);
void srand(unsigned seed);Typy
ino_t
Used for file serial numbers.#include <stdio.h>
typedef /* ... */ FILE;An object type used for streams.Makra
S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISREG, S_ISLNK, S_ISSOCK
S_ISBLK(m)
Test for a block special file.
S_ISCHR(m)
Test for a character special file.
S_ISDIR(m)
Test for a directory.
S_ISFIFO(m)
Test for a pipe or FIFO special file.
S_ISREG(m)
Test for a regular file.
S_ISLNK(m)
Test for a symbolic link.
S_ISSOCK(m)
Test for a socket.S_TYPEISMQ, S_TYPEISSEM, S_TYPEISSHM, S_TYPEISTMO
S_TYPEISMQ(buf)
Test for a message queue.
S_TYPEISSEM(buf)
Test for a semaphore.
S_TYPEISSHM(buf)
Test for a shared memory object.
S_TYPEISTMO(buf)
Test macro for a typed memory object.Materialy źródłowe
L1: Gotowe zadania przykładowe 1-4
man
Struktury i nagłówki
Typy i makra
S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISREG, S_ISLNK, S_ISSOCK
S_TYPEISMQ, S_TYPEISSEM, S_TYPEISSHM, S_TYPEISTMO