Skip to Content
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
For Enterprise
For Government
For Higher Ed
For Individuals
For Marketing
Explore Skills
Cloud Computing
Microsoft Azure
Amazon Web Services (AWS)
Google Cloud
Cloud Migration
Cloud Deployment
Cloud Platforms
Data Engineering
Data Warehouse
SQL
Apache Spark
Microsoft SQL Server
MySQL
Kafka
Data Lake
Streaming & Messaging
NoSQL Databases
Relational Databases
Data Science
Pandas
R
MATLAB
SAS
D3
Power BI
Tableau
Statistics
Exploratory Data Analysis
Data Visualization
AI & ML
Generative AI
Machine Learning
Artificial Intelligence (AI)
Deep Learning
Reinforcement Learning
Natural Language Processing
TensorFlow
Scikit-Learn
Hyperparameter Tuning
MLOps
Programming Languages
Java
JavaScript
Spring
Python
Go
C#
C++
C
Swift
Rust
Functional Programming
Software Architecture
Object-Oriented
Distributed Systems
Domain-Driven Design
Architectural Patterns
IT/Ops
Kubernetes
Docker
GitHub
Terraform
Continuous Delivery
Continuous Integration
Database Administration
Computer Networking
Operating Systems
IT Certifications
Security
Network Security
Application Security
Incident Response
Zero Trust Model
Disaster Recovery
Penetration Testing / Ethical Hacking
Governance
Malware
Security Architecture
Security Engineering
Security Certifications
Design
Web Design
Graphic Design
Interaction Design
Film & Video
User Experience (UX)
Design Process
Design Tools
Business
Agile
Project Management
Product Management
Marketing
Human Resources
Finance
Team Management
Business Strategy
Digital Transformation
Organizational Leadership
Soft Skills
Professional Communication
Emotional Intelligence
Presentation Skills
Innovation
Critical Thinking
Public Speaking
Collaboration
Personal Productivity
Confidence / Motivation
Features
All features
Verifiable skills
AI Academy
Courses
Certifications
Interactive learning
Live events
Superstreams
Answers
Insights reporting
Radar Blog
Buy Courses
Plans
Sign In
Try Now
O'Reilly Platform
book
LINUX系統程式設計 第二版
by
Robert Love
December 2013
Intermediate to advanced
496 pages
8h 57m
Chinese
GoTop Information, Inc.
Content preview from
LINUX系統程式設計 第二版
46
|
第二章
EIO
同步期間發生了一個低階的
I/O
錯誤。這代表一個真正的
I/O
錯誤,而且往往出現在
會發生此類錯誤的地方。
在某些
Linux
版本中,叫用
fsync()
或許會失敗,因為背後的檔案系統可能並未實作
fsync()
,即使它有實作
fdatasync()
。如果
fsync()
傳回
EINVAL
,有此疑慮的應用程式可
能會想嘗試
fdatasync()
。例如:
if (fsync (fd) ==
−
1) {
/*
*
我們偏好
fsync()
,但是如果
fsync()
失敗了,
*
讓我們試試
fdatasync()
。
*/
if (errno == EINVAL) {
if (fdatasync (fd) ==
−
1)
perror ("fdatasync");
} else
perror ("fsync");
}
因為
POSIX
需要
fsync()
,而
fdatasync()
只是一個選項,所以任何一般的
Linux
檔案系
統,總是應該為正規檔案實作
fsync()
系統呼叫。然而,老舊的檔案型態(或許沒有中
介資料需要同步)或奇怪的檔案系統可能只會實作
fdatasync()
。
sync()
雖然不是最理想的,但是應用範圍較廣的老式
sync()
系統呼叫,可讓
所有
緩衝區與磁碟
同步:
#include <unistd.h>
void sync (void);
此函式不需要參數,也沒有傳回值。它總是能成功並且返回,所有的緩衝區(包括資料
和中介資料)保證都會寫回磁碟。
4
標準並不要求
sync()
必須等到所有緩衝區全都出清到磁碟才返回;標準只要求該呼叫, ...
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科學研究的美學
Juan Nunez-Iglesias, Stéfan van der Walt, Harriet Dashnow
成為卓越程式設計師的38項必修法則
Pete Goodliffe
深入理解運算原理|從簡單的機器到無所不能的程式
Tom Stuart
C++语言导学(原书第2版)
本贾尼 斯特劳斯特鲁普
Publisher Resources
ISBN: 9789862769812