Skip to Content
LINUX系統程式設計 第二版
book

LINUX系統程式設計 第二版

by Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from LINUX系統程式設計 第二版
256
|
第八章
stat 系列函式
Unix 提供了一系列的函式可用於取得一個檔案的中介資料:
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int stat (const char *path, struct stat *buf);
int fstat (int fd, struct stat *buf);
int lstat (const char *path, struct stat *buf);
這些函式都會傳回與一個檔案有關的資訊。
stat()
會傳回
path
所代表之檔案的相關
資訊,而
fstat()
函式會傳回檔案描述器
fd
所代表之檔案的相關資訊。
lstat()
如同
stat()
,除了符號連結的情況:
lstat()
所傳回的是關於連結本身(而非目標檔案)的
資訊。
這些函式都會把資訊存入一個
stat
結構(提供自用戶)。
stat
結構定義於
<bits/stat.
h>
,因此可以從
<sys/stat.h>
來引用它:
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* permissions */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

優雅的SciPy|Python科學研究的美學

優雅的SciPy|Python科學研究的美學

Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普

Publisher Resources

ISBN: 9789862769812