Linux file

  
To access the disk file, you must return a ID associated with the file through the system call. This ID is the file descriptor file descriptorlinux operating system provides an open system call, any process to access a file, First use this open to open this file, the system will return a number, and the file descriptor associated with this file (1) user program from the user from the user space to the kernel to open the application (2) the operating system will go in the kernel Check whether the request is legal. If it is legal to apply for opening the file related information in the kernel (read and write location, location on the disk, use struct file to store) and add it to the current process PCB open file list array, corresponding to this The array subscript and the file descriptor (3) return the file descriptor to the non-use space. The user space then reads and writes the file through this number value ---------------- -------------------------------------------------- ----------------------------------- -------------------------------------------------- -- The system defaults to open three files for each process: printf/scanf: file descriptor value 0 (standard input, keyboard) 1 (standard output, display) 2 (standard error output, display) corresponding macro STDIN_FILENOSTDOUT_FILENOSTDERR_FILENO
Copyright © Windows knowledge All Rights Reserved