HomeFedun.SiteGitHubTelegram

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

struct dirent

ino_t  d_ino       File serial number.
char   d_name[]    Filename string of entry.

DIR

DIR
  A type representing a directory stream. The DIR type may be an incomplete type.

struct stat

#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
};

iovec

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.

pollfd

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

readdir

#include <dirent.h>
 
struct dirent *readdir(DIR *dirp);

fdopendir, opendir

#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.

closedir

#include <dirent.h>
 
int closedir(DIR *dirp);

chdir

#include <unistd.h>
 
int chdir(const char *path);

getcwd

#include <unistd.h>
 
char *getcwd(char *buf, size_t size);

mkdir

#include <sys/stat.h>
 
int mkdir(const char *path, mode_t mode);

Pliki

Więcej informacji na SOP@MINI

fopen

#include <stdio.h>
 
FILE *fopen(const char *restrict pathname, const char *restrict mode);

fseek

#include <stdio.h>
 
int fseek(FILE *stream, long offset, int whence);

fclose

#include <stdio.h>
 
int fclose(FILE *stream);

fprintf

#include <stdio.h>
 
int fprintf(FILE *restrict stream, const char *restrict format, ...);

fputc

#include <stdio.h>
 
int fputc(int c, FILE *stream);

fputs

#include <stdio.h>
 
int fputs(const char *restrict s, FILE *restrict stream);

fwrite

#include <stdio.h>
 
size_t fwrite(const void *restrict ptr, size_t size, size_t nitems,
  FILE *restrict stream);

fscanf

#include <stdio.h>
 
int fscanf(FILE *restrict stream, const char *restrict format, ...);

fgetc

#include <stdio.h>
 
int fgetc(FILE *stream);

fgets

#include <stdio.h>
 
char *fgets(char *restrict s, int n, FILE *restrict stream);

fread

#include <stdio.h>
 
size_t fread(void *restrict ptr, size_t size, size_t nitems,
  FILE *restrict stream);

link

#include <unistd.h>
 
int link(const char *path1, const char *path2);

readlink

#include <unistd.h>
 
ssize_t readlink(const char *restrict path, char *restrict buf,
  size_t bufsize);

open

#include <fcntl.h>
 
int open(const char *path, int oflags, ...);

close

#include <unistd.h>
 
int close(int fildes);

read

#include <unistd.h>
 
ssize_t read(int fildes, void *buf, size_t nbyte);

write

#include <unistd.h>
 
ssize_t write(int fildes, const void *buf, size_t nbyte);

lseek

#include <unistd.h>
 
off_t lseek(int fildes, off_t offset, int whence);

writev

#include <sys/uio.h>
 
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt);

readv

#include <sys/uio.h>
 
ssize_t readv(int fildes, const struct iovec *iov, int iovcnt);

mmap

#include <sys/mman.h>
 
void *mmap(void *addr, size_t len, int prot, int flags,
    int fildes, off_t off);

fcntl

#include <fcntl.h>
 
int fcntl(int fildes, int cmd, ...);

poll

#include <poll.h>
 
int poll(struct pollfd fds[], nfds_t nfds, int timeout);

symlink

#include <unistd.h>
 
int symlink(const char *path1, const char *path2);

Pozostałe (Miscellaneous)

stat, lstat

#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.

chmod

#include <sys/stat.h>
 
int chmod(const char *path, mode_t mode);

access

#include <unistd.h>
 
int access(const char *path, int amode);

rand, srand

#include <stdlib.h>
 
int rand(void);
void srand(unsigned seed);

Typy

ino_t (inode type) :

ino_t
  Used for file serial numbers.

FILE :

#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

Strona SOP@MINI

L1: Gotowe zadania przykładowe 1-4

man

Struktury i nagłówki

dirent.h(0p)

struct dirent

DIR

sys_stat.h(0p)

struct stat

stat(3type)

sys_uio.h(0p)

struct iovec

poll.h(0p)

struct pollfd

inode(7)

sys_types.h(0p)

FILE(3type)

Typy i makra

ino_t

S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISREG, S_ISLNK, S_ISSOCK

S_TYPEISMQ, S_TYPEISSEM, S_TYPEISSHM, S_TYPEISTMO

Funkcje

fdopendir(3p)

opendir(3p)

closedir(3p)

readdir(3p)

getcwd(3p)

chdir(3p)

mkdir(3p)

fopen(3p)

fclose(3p)

fseek(3p)

fprintf(3p)

fputc(3p)

fputs(3p)

fwrite(3p)

fscanf(3p)

fgetc(3p)

fgets(3p)

fread(3p)

link(3p)

readlink(3p)

open(3p)

close(3p)

read(3p)

write(3p)

lseek(3p)

writev(3p)

readv(3p)

mmap(3p)

fcntl(3p)

poll(3p)

symlink(3p)

stat(3p)

lstat(3p)

chmod(3p)

access(3p)

rand(3p)

srand(3p)

Pozostałe materiały

unlink(3p)

umask(3p)

mknod(3p)