├── System_Call.pdf ├── OSSP_Individual_Yonas-Adane-Admasu_BDU1602840.pdf ├── README.md └── Getdents().c /System_Call.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Triomill/Yonas_Elementary-Os/HEAD/System_Call.pdf -------------------------------------------------------------------------------- /OSSP_Individual_Yonas-Adane-Admasu_BDU1602840.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Triomill/Yonas_Elementary-Os/HEAD/OSSP_Individual_Yonas-Adane-Admasu_BDU1602840.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Elementary OS 8.0 Installation 2 | Elementary OS is a sleek, Ubuntu-based distribution focused on simplicity and minimalism. Designed for users who prefer a clean and intuitive interface, it features the Pantheon desktop environment. The OS emphasizes privacy, performance, and a refined user experience. Elementary OS 8.0 includes essential apps and tools out of the box, offering a smooth setup process and polished design for everyday computing. 3 | # System Call: getdents() 4 | The getdents() system call reads several directory entries from a file descriptor into a user-provided buffer. It returns data in a low-level format and is used internally by commands like ls. It allows programs to list files in a directory without high-level libraries. Requires careful handling of raw binary data and is replaced in modern code by higher-level functions like readdir() for safety and simplicity. 5 | -------------------------------------------------------------------------------- /Getdents().c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #define BUF_SIZE 4096 9 | #ifndef __NR_getdents 10 | #define __NR_getdents 78 11 | #endif 12 | struct linux_dirent { 13 | unsigned long d_ino; 14 | off_t d_off; 15 | unsigned short d_reclen; 16 | char d_name[]; 17 | }; 18 | int main(int argc, char *argv[]) { 19 | int fd; 20 | char buf[BUF_SIZE]; 21 | struct linux_dirent *d; 22 | int bpos; 23 | char *dirpath = "."; 24 | if (argc > 1) { 25 | dirpath = argv[1]; 26 | } 27 | fd = open(dirpath, O_RDONLY | O_DIRECTORY); 28 | if (fd == -1) { 29 | perror("open"); 30 | exit(EXIT_FAILURE); 31 | } 32 | printf("Contents of '%s':\n", dirpath); 33 | printf("INODE\t\tNAME\n"); 34 | while (1) { 35 | int nread = syscall(__NR_getdents, fd, buf, BUF_SIZE); 36 | if (nread == -1) { 37 | perror("getdents"); 38 | close(fd); 39 | exit(EXIT_FAILURE); 40 | } 41 | if (nread == 0) break; 42 | for (bpos = 0; bpos < nread;) { 43 | d = (struct linux_dirent *)(buf + bpos); 44 | printf("%-10lu\t%s\n", d->d_ino, d->d_name); 45 | bpos += d->d_reclen; 46 | } } 47 | close(fd); 48 | return 0; 49 | } --------------------------------------------------------------------------------