Files and Directories

慕鸿波
2023-12-01

Introduction

  • stat functions,describe each of these
  • look more details of the structure of the Unix file system and symbolic links
  • operate on directories adn some others.

stat,fstat,fstatat,lstat functions

  • given a pathname,the stat function returns a structure of information about the named file.
  • the fstat function obtains information about the file that has opened on the descriptor fd.
  • lstat function returns information about the symbolic link,not the file it referenced.
  • the fstatat function provides a way to return the file statistics for a pathname relative to an open directory represented by the fd argument.,when the AT_SYMLINK_NOFOLLOW flag is set,fstatat will not follow symbolic links,returning information about the file to which the symbolic link points

file types

  • most files on Unix system ae regular files or directories,but there are also some other types:
    – regular file:the most common type of file,which contains data of some form.
    – directory file:a file that contains the names of other files and pointers to information on these files,only the kernel can write directly to a directory file.Process must use the functions to make changes to a directory
    – block special file:a type of file providing buffered I/O access in fixed-size units to devices such as disk drives.
    – character special file:a type of file providing unbuffered I/O access in variable-sized units to devices.All devices on a system are either block special files or character special files.
    – FIFO:a type of file used for communication between processes,it also called named pipo.
    –socket:a type of file for network communication between processes,and a socket can also be used for non-network communication between processes on a single host
    – symbolic link:a type file that points to another file.

to be continued…

 类似资料:

相关阅读

相关文章

相关问答