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系統程式設計 第二版
306
|
第八章
inotify 事件
inotify_event
結構,定義於
<inotify.h>
,可用於表示 inotify 事件:
#include <sys/inotify.h>
struct inotify_event {
int wd; /* watch descriptor */
uint32_t mask; /* mask of events */
uint32_t cookie; /* unique cookie */
uint32_t len; /* size of 'name' field */
char name[]; /* nul-terminated name */
};
wd
用於指定檢視描述器,取得自
inotify_add_watch()
,而
mask
代表事件。如果
wd
指定
了一個目錄,而且要檢視該目錄中一個檔案所發生的一個事件,則
name
所提供的檔案
名稱會相對於該目錄。此狀況下,
len
是一個非零值。請注意,
len
不同於
name
的字串
長度;
name
的結尾可能不只一個 null 字符,其作用有如補白,以確保後續的
inotify_
event
能夠被正確對齊。因此,你必須使用
len
(而不要使用
strlen()
)來計算一個陣列
中下一個
inotify_event
結構的偏移值。
零長度陣列
name
是零長度陣列的一個例子。零長度陣列,也稱為伸縮陣列(flexible array),
C99 語言的一個功能,它讓我們得以建立可變長度陣列。它們具有一個非常強
大的用途:將可變長度的陣列嵌入結構 ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

深入理解運算原理|從簡單的機器到無所不能的程式

深入理解運算原理|從簡單的機器到無所不能的程式

Tom Stuart
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow

Publisher Resources

ISBN: 9789862769812