본문 바로가기

전체 글6

[Linux] 커널 컴파일(build linux kernel) (1) 내 환경~$ uname -aLinux ubuntu-linux-22-04-desktop 5.15.0-41-generic #44-Ubuntu SMP Thu Jun 23 11:20:13 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux1. 커널 소스 다운로드 받기$ cd /usr/src/usr/src$ wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.27.tar.xz/usr/src$ tar -xvf linux-6.12.27.tar.xz1.5. 문서 읽기⭐ 커널 컴파일을 시도하면서 문서를 읽는 것이 매우 중요하다는 걸 뼈저리게 느꼈습니다. 블로그 보지 말고 문서 보십쇼. 문서!READMEDocumentation/admin-g.. 2025. 5. 8.
LinuxSP - Standard I/O Library: 함수 fopen(3), freopen(3), fdopen(3)#include FILE *fopen(constage char *pathname, const char *mode);FILE *fdopen(int filedes, const char *mode);FILE *freopen(const char *pathname, const char *mode, FILE *fp);/* return: On success → file pointer / On error → NULL, errno is set */struct FILEtypedef struct { int cnt; unsigned char *base; unsigned char *ptr; unsigned flag; int fd;} FIL.. 2025. 4. 25.
LinuxSP - Files and Directories: 함수 stat(2), fstat(2), lstat(2)#include #include #include int stat(const char *restrict pathname, struct stat *restrict statbuf);int fstat(int fd, struct stat *statbuf);int lstat(const char *restrict pathname, struct stat *restrict statbuf);/* 심볼릭 링크 파일 자체에 대한 정보를 반환함 *//* return: 성공 → 0 / 에러 → -1 */ - 여기서 restrict pathname, restrict statbuf는 두 포인터가 서로 같은 메모리 영역을 참조하지 않음을 보장한다.- stat 함수의 첫 번째 인자로 심볼.. 2025. 4. 25.
LinuxSP - Files and Directories: 개념 struct stat/usr/include/x86_64-linux-gnu/bits/struct_stat.hstruct stat {#ifdef __USE_TIME_BITS64# include #else __dev_t st_dev; /* Device. */# ifndef __x86_64__ unsigned short int __pad1;# endif# if defined __x86_64__ || !defined __USE_FILE_OFFSET64 __ino_t st_ino; /* File serial number. */# else __ino_t __st_ino; /* 32bit file serial number. */# endif# ifndef __x86_64__ __m.. 2025. 4. 25.
LinuxSP - FILE I/O: 함수 open(2)파일을 오픈하거나 생성할 때 사용하는 시스템 호출 함수(2)이다.#include #include #include int open(const char *pathname, int oflag, ... /* mode_t mode */);/* return: 파일 열기 성공 → 파일 디스크립터 번호 / 에러 → -1 */​* oflag argumentsO_RDONLYopen for reading onlyO_WRONLYopen for writing onlyO_RDWRopen for reading and writingO_APPENDThe file is opened in append mode.O_CREATIf pathname does not exist, create it as a regular file.O_.. 2025. 4. 24.
LinuxSP - FILE I/O: 개념 Linux, Unix에서 데이터를 읽거나 쓸 수 있는 모든 객체를 파일이라고 한다. 스토리지에 저장되는 일반 파일(반대로 특별 파일이 있음)뿐만 아니라 모든 디바이스를 파일로 취급한다. 파일을 "바이트 단위의 순차적인 스트림"으로 처리한다. 파일 디스크립터 (file descriptor)파일 디스크립터는 파일을 입출력으로 다룰 수 있게 하고, 커널 내부 자료 구조들과의 연결 통로 역할을 하는 것이다.open(), creat(), dup()의 리턴 값read(), write(), fsync(), fdatasync()의 첫 번째 인자 fd[0] == stdin (STDIN_FILENO) / fd[1] == stdout (STDOUT_FILENO) / fd[2] == stderr (STDERR_FILENO)/.. 2025. 4. 24.