加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Advanced Programming in UNIX Environment Episode 17

发布时间:2020-12-15 09:15:52 所属栏目:安全 来源:网络整理
导读:rename和renameat函数 #include stdio.h int rename( const char *oldname, const char *newname); int renameat( int oldfd, const char *oldname, int newfd, const char *newname); 引入符号链接的原因是为了避开硬链接的一些限制。 硬链接通常要求链接和

rename和renameat函数

#include <stdio.h>

int rename(const char *oldname,const char *newname);
int renameat(int oldfd,const char *oldname,int newfd,const char *newname);

引入符号链接的原因是为了避开硬链接的一些限制。

  • 硬链接通常要求链接和文件位于同一文件系统中
  • 只有超级用户才能创建指向目录的硬链接

    用symlink或symlinkat函数创建一个符号链接。

#include <unistd.h>

int symlink(const char *actualpath,const char *sympath);
int symlinkat(const char *actualpath,int fd,const char *sympath);

打开该链接本身,并读取该链接中的名字。readlink和readlinkat函数提供了这种功能。

#include <unistd.h>

ssize_t readlink(const char *restrict pathname,char *restrict buf,size_t bufsize);
ssize_t readlinkat(int fd,const char *restrict pathname,size_t bufsize);

futimens和utimensat函数可以指定纳秒级精度的时间戳。

#include <unistd.h>

int futimes(int fd,const struct timespec times[2]);
int utimensat(int fd,const char *path,const struct timespec times[2],int flag);

futimes和utimensat函数都包含在POSIX.1中,第3个函数utimes包含在Single UNIX Specification的XSI扩展中。

#include <sys/time.h>

int utimes(const char *pathname,const struct timeval times[2])

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读