zoukankan      html  css  js  c++  java
  • 文件扩展属性

    扩展属性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不存在,则失败

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

  • 相关阅读:
    将博客搬至CSDN
    defender 月考总结
    生日祝福@陈俊翰
    个性签名
    你这是virus吧?
    (CPSCA's)CPOJC+VIJOS
    Sentence by defender
    工作制一览
    最长上升子序列
    mysql约束
  • 原文地址:https://www.cnblogs.com/biaopei/p/7730617.html
Copyright © 2011-2022 走看看