文件扩展属性

扩展属性EA,既以名称-值对形式将任意元数据与文件i
节点关联起来的技术
在shell中操作

[root@bogon code]# setfattr -n user.x -v "this is first" linux
[root@bogon code]# setfattr -n user.y -v "this is first" linux      //为linux文件设置扩展属性
[root@bogon code]# getfattr -d linux    //-d显示文件linux的全部扩展属性
# file: linux
user.x="this is first"
user.y="this is first"

[root@bogon code]# setfattr -n user.x linux //令user.x的linux属性为空
[root@bogon code]# getfattr -d linux
# file: linux
user.x
user.y="this is first"

[root@bogon code]# setfattr -x user.y linux //删除linux文件的user.y 
[root@bogon code]# getfattr -d linux
# file: linux
user.x

[root@bogon code]# 

使用函数设置EA

#include<sys/xattr.h>
int setxattr(const char *pathname,const char *name,const void *value,size_t size,int flags)
int lsetxattr(const char *pathname,const char *name,const void *value,size_t size,int flags)
int fsetxattr(int fd,const char *name,const void *value,size_t size,int flags)
flags的值可以为XATTR_CREATE 如果给定名称name的EA已经存在,则失败,XATTR_REPLACE  给定名称name的EA不存在,则失败

这里写图片描述
这里写图片描述
这里写图片描述

posted on 2017-10-25 18:06  标配的小号  阅读(442)  评论(0编辑  收藏  举报

导航