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系統程式設計 第二版
檔案與目錄的管理
|
289
另一種連結型態稱為
符號連結
symbolic link
)。儘管此類連結不具檔案系統的映射,但
是它具有一個在執行期解譯(interpreted at runtime)的較高階指標。此類連結可以跨檔
案系統—稍後馬上會看到。
硬連結
link()
系統呼叫,原本是 Unix 的一個系統呼叫,不過現在是經過 POSIX 標準化的系統
呼叫,可用於替現存的檔案建立一個新的連結:
#include <unistd.h>
int link (const char *oldpath, const char *newpath);
執行成功時,
link()
會替現存檔案
oldpath
以路徑
newpath
建立一個新的連結,然後會傳
0
。完成呼叫後,
oldpath
newpath
會指向同一個檔案—事實上,你無法區分哪一個
是最初的連結。
執行失敗時,此呼叫會傳回
-1
而且會把
errno
設定為下面其中一個值:
EACCESS
進行調用之行程對
oldpath
中的一個元件不具搜尋的權限,或者進行調用之行程對包
newpath
的目錄不具寫入的權限。
EEXIST
newpath
已經存在—
link()
無法改寫現存的目錄項目。
EFAULT
oldpath
newpath
是一個無效的指標。
EIO
發生了一個內部的 I/O 錯誤(這是很嚴重的情況!)。
ELOOP
解析
oldpath
newpath
的時候遇到了太多的符號連結。
EMLINK
oldpath
所指向的 inode 已經達到了可以指向它的連結數目上限。 ...
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