更改文件属性

文件属性修改全攻略:创建日期更改与批量管理实战 反映的是文件内容最后一次发生变化的时间。任何写入操作(包括追加、覆盖、截断)都会触发此时间更新。它是大多数备份软件(如 Windows Backup、Veeam)判断增量备份范围的核心依据。典型应用案例:# 查找过去24小时内修改过的所有文本文件该命令利用实现快速定位变更文件,适用于故障排查或合规检查。记录文件最后一次被读取的时间。然而,出于性能考虑,自 Windows Vista 起,默认禁用了该字段的实时更新。 阅读详情

    在mac os x 上去隐藏一个文件或者是一个文件夹。可以通过在文件前面加“.”,在有安装了开发工具带有一个工具可以实现。那就是SetFile。他可以更改文件的属性。

     隐藏一个文件:

                        SetFile -a V /filepath

     显示一个文件:

                        SetFile -a vV /filepath

   在开发中想隐藏一个文件我还没找到什么好方法。在Windows上通过更改注册表和文件的hide属性。

 

下面是一个在posix级上对VFAT的支持。

Posix file attribute support on VFAT

Ogawa-san and FAT developpers,


 vfat-posix_attr.patch:

 fs/fat/file.c            |   10 +
 fs/fat/inode.c           |   27 +++
 fs/vfat/namei.c          |  291 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/msdos_fs.h |  320 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 646 insertions(+), 2 deletions(-)

This patch enables "posix_attr" option described as following;


"posix_attr" mapping support on VFAT.

- Descriptions

The option "posix_attr" enables attribute mapping from POSIX
special files and permission modes/attributes to VFAT attributes
and creation time fields.

On memory resident inode storage holds full posix attributes,
however in media side, VFAT can't have enough room to store all
attributes. So attribute mapping taken by this option
is designed to be minimal.

For newly created and/or modified files/dirs, system can utilize
full posix attributes, because memory resident inode storage can
hold those. After umount-mount cycle, system may lose some
attributes to preserve VFAT format.

This mapping method has many restrictions, however it's
very handy to build root file system with FAT for small embedded
device where inter-operation with PC is needed.

- Features
 
Following attributes/modes are supported with this option
in VFAT media side. However, on memory resident inode storage
holds full posix attributes.  That means, for newly created and/or
modified files/dirs, system can utilize full posix attributes.
After umount-mount cycle, system can just keep following
attributes/modes.

  - FileType
 File type is held in 3MSB bits in ctime_cs.
 This enables support following special files.
  symbolic link,
  block device node,
  char device node,
  fifo,
  socket
 Regular files also may have POSIX attributes.

  - DeviceFile
 Major and minor number would be held at ctime
 and both values are limited  to 255.

  - Owner's User ID/Group ID:  2nd LSB bit in ctime_cs
 This can be used to distinguish root and others,
 because this has just one bit width.
 Value of UID/GID for non-root user will be taken from uid/gid
 option on mounting. If nothing is specified, system uses -1 as
 last resort.

  - Permission for Group/Other (rwx): 3rd-5th LSB bit in ctime_cs
 Those modes will be kept in ctime_cs.
 Also permission modes for "others" will be
 same as "group", due to lack of fields.

  - Permission for Owner (rwx)
 These modes will be mapped to FAT attributes.
 Just same as mapping under VFAT.

  - Others
 no sticky, setgid nor setuid bits are not supported.

- Algorithm for attribute mapping decision

  - Regular file/dir
 To distinguish regular files/dirs, look if this fat dir
 entry doesn't have ATTR_SYS, first. If it doesn't have
 ATTR_SYS, then check if TYPE field (MSB 3bits) in ctime_cs
 is equal to 7. If so, this regular file/dir is created and/or
 modified under VFAT with "poisx_attr". And posix attribute
 mapping can be take place. Otherwise, conventional VFAT
 attribute mapping is used.

  - Special file
 To distinguish special files, look if this fat dir entry
 has ATTR_SYS, first. If it has ATTR_SYS, then check
 1st. LSB bit in ctime_cs, refered as "special file flag".
 If set,  this file is created under VFAT with "posix_attr".
 Look up TYPE field to decide special file type.
 This spcial file detection mothod has some flaw to make
 potential confusion. E.g. some system file created under
 dos/win may be treated as special file.  However in most case,
 user don't create system file under dos/win.


- FAT DIR entry fields description

  - ctime_cs

     8bit byte
 7 6 5 4 3 2 1 0
 |===| | | | | |
 TYPE  | | | | +- special file flag (vaild if ATTR_SYS)
       | | | +--- User/Group ID(owner)
       | | +----- !group X
       | +------- !group W
       +--------- !group R

  

 special file flag
  Indicate this entry has posix attribut mapping.
  This field is vaild for fat dir entry, which
  have ATTR_SYS.

 special file TYPE
  val type on VFS(val) Description
  ------------------------------------------------
  0  (place folder for backword compat)
  1  DT_LNK (10)  symbolic link
  2 DT_BLK (6)  block dev
  3 DT_CHR (4)  char dev
  4 DT_FIFO (1)  fifo
  5 DT_SOCK (12)  socket
 
  7 (resevered for DT_REG/DT_DIR) *)

  *)Value 7 is reserved for regular file/dir (DT_REG/DT_DIR).
  Normally ctime_cs would have 0-199 value to stand for
  up to 2sec. The value for DT_REG/DT_DIR is selected
  to be over this range to distinguish if file was created
  under POSIX_ATTR or not.

  - attr
 FAT attribute (val)  mapped attribute
 ------------------------------------------------
 ATTR_RO  0x01   !owner W
 ATTR_HIDDEN 0x02  !owner R
 ATTR_SYS 0x04
 ATTR_VOLUME 0x08
 ATTR_DIR 0x10  DIR
 ATTR_ARCH 0x20  !owner X

  - ctime
  16bit word
 f e d c b a 9 8 7 6 5 4 3 2 1 0
 |=============| |-------------|
   major    minor


---
M  fs/fat/file.c
M  fs/vfat/namei.c
M  include/linux/msdos_fs.h
M  fs/fat/inode.c

* modified files

--- orig/fs/fat/file.c
+++ mod/fs/fat/file.c

   error = 0;
   goto out;
  }
 if (sbi->options.posix_attr){
  error = inode_setattr(inode, attr);
  goto out;
 }
  if (((attr->ia_valid & ATTR_UID) &&
       (attr->ia_uid != sbi->options.fs_uid)) ||
      ((attr->ia_valid & ATTR_GID) &&

  .truncate = fat_truncate,
  .setattr = fat_notify_change,
 };

struct inode_operations fat_symlink_inode_operations = {
       .readlink       = page_readlink,
       .follow_link    = page_follow_link_light,
       .setattr        = fat_notify_change,
};


--- orig/fs/fat/inode.c
+++ mod/fs/fat/inode.c

   MSDOS_I(inode)->i_logstart = MSDOS_I(inode)->i_start;
   inode->i_size = le32_to_cpu(de->size);
   inode->i_op = &fat_file_inode_operations;
  if (sbi->options.posix_attr
   && is_vfat_posix_symlink(inode, de)){
    inode->i_op = &fat_symlink_inode_operations;
  }
   inode->i_fop = &fat_file_operations;
   inode->i_mapping->a_ops = &fat_aops;
   MSDOS_I(inode)->mmu_private = inode->i_size;

  fat_date_unix2dos(inode->i_mtime.tv_sec, &raw_entry->time, &raw_entry->date);
  if (sbi->options.isvfat) {
   fat_date_unix2dos(inode->i_ctime.tv_sec,&raw_entry->ctime,&raw_entry->cdate);
  raw_entry->ctime_cs = (inode->i_ctime.tv_sec & 1) * 100 +
   inode->i_ctime.tv_nsec / 10000000;
  if (set_vfat_posix_attr(raw_entry, inode) == -1) {
   raw_entry->ctime_cs
    = (inode->i_ctime.tv_sec & 1) * 100 +
     inode->i_ctime.tv_nsec / 10000000;
  }
  }
  spin_unlock(&sbi->inode_hash_lock);
  mark_buffer_dirty(bh);

    seq_puts(m, ",uni_xlate");
   if (!opts->numtail)
    seq_puts(m, ",nonumtail");
  if (opts->posix_attr)
   seq_puts(m, ",posix_attr");
 }
 
  return 0;

  Opt_charset, Opt_shortname_lower, Opt_shortname_win95,
  Opt_shortname_winnt, Opt_shortname_mixed, Opt_utf8_no, Opt_utf8_yes,
  Opt_uni_xl_no, Opt_uni_xl_yes, Opt_nonumtail_no, Opt_nonumtail_yes,
 Opt_posix_attr_no, Opt_posix_attr_yes,
  Opt_obsolate, Opt_err,
 };
 

  {Opt_nonumtail_yes, "nonumtail=yes"},
  {Opt_nonumtail_yes, "nonumtail=true"},
  {Opt_nonumtail_yes, "nonumtail"},
 {Opt_posix_attr_no, "posix_attr=0"},  /* 0 or no or false */
 {Opt_posix_attr_no, "posix_attr=no"},
 {Opt_posix_attr_no, "posix_attr=false"},
 {Opt_posix_attr_yes, "posix_attr=1"}, /* empty or 1 or yes or true */
 {Opt_posix_attr_yes, "posix_attr=yes"},
 {Opt_posix_attr_yes, "posix_attr=true"},
 {Opt_posix_attr_yes, "posix_attr"},
 {Opt_err, NULL}
 };


   case Opt_nonumtail_yes:  /* empty or 1 or yes or true */
    opts->numtail = 0; /* negated option */
   break;
  case Opt_posix_attr_no:  /* 0 or no or false */
   opts->posix_attr = 0;
   break;
  case Opt_posix_attr_yes: /* empty or 1 or yes or true */
   opts->posix_attr = 1;
   break;
 
  /* obsolete mount options */
   case Opt_obsolate:


--- orig/fs/vfat/namei.c
+++ mod/fs/vfat/namei.c

 #include <linux/smp_lock.h>
 #include <linux/buffer_head.h>
 #include <linux/namei.h>
 #include <linux/fs.h>

#define GET_INODE_FILE_TYPE(x) (((x)->i_mode & 0xf000) >> 12)
#define GET_INODE_OWNER_R(x) (((x)->i_mode & 0x0100) >> 8)
#define GET_INODE_OWNER_W(x) (((x)->i_mode & 0x0080) >> 7)
#define GET_INODE_OWNER_X(x) (((x)->i_mode & 0x0040) >> 6)
#define GET_INODE_GROUP_R(x) (((x)->i_mode & 0x0020) >> 5)
+#define GET_INODE_GROUP_W(x) (((x)->i_mode & 0x0010) >> 4)
#define GET_INODE_GROUP_X(x) (((x)->i_mode & 0x0008) >> 3)
#define GET_INODE_USER_ID(x) ((x)->i_uid ? 1 : 0)
#define GET_INODE_DRV_MAJOR(x) ((x)->i_rdev >> MINORBITS)
+#define GET_INODE_DRV_MINOR(x) ((x)->i_rdev & MINORMASK)

static unsigned short  filetype_table[] = {
 DT_REG, /* place folder for backward compat */
 DT_LNK,
 DT_BLK,
 DT_CHR,
 DT_FIFO,
 DT_SOCK,
 0
};

/**
 is_vfat_posix_symlink - check if posix file type from VFAT dir is symlink
 
  Returns
          0 ... is not symlink or don't have posix attributes
  otherwise ... is symlink
 /
int is_vfat_posix_symlink(struct inode *inode, struct msdos_dir_entry *dentry)
{
 if (get_fat_attr_sys(dentry) && get_posix_attr_spec_file(dentry)) {
  return (filetype_table[get_posix_attr_file_type(dentry)]
   == DT_LNK);
 }
 return 0;
}

/*
  get_vfat_posix_attr - Retrieve posix attributes from VFAT dir entry
 /
static inline
void get_vfat_posix_attr(struct inode *inode, struct msdos_dir_entry *dentry)
{
 int uid;
 int gid;
 struct msdos_sb_info *sbi;
 int ftype;

 if (!(inode && dentry) || IS_ERR(inode))
  goto out;
 sbi = MSDOS_SB(inode->i_sb);
 if (!sbi->options.posix_attr)
  goto out;

 /* File type : 0xF000 : 12 */
 ftype = -1;
 if (!get_fat_attr_sys(dentry)) {
  if (get_posix_attr_reg_file(dentry))
   ftype = get_fat_attr_dir(dentry) ? DT_DIR : DT_REG;
 } else if (get_posix_attr_spec_file(dentry)) {
  ftype = filetype_table[get_posix_attr_file_type(dentry)];
 }
 if (ftype == -1)
  goto out;
 inode->i_mode = ftype << 12;
 /* Owner : 0x01C0) : 6 */
 inode->i_mode |= (((get_posix_attr_owner_r(dentry) << 2)
  | (get_posix_attr_owner_w(dentry) << 1)
  | get_posix_attr_owner_x(dentry)) << 6);
 /* Group : 0x0038) : 3 */
 inode->i_mode |= (((get_posix_attr_group_r(dentry) << 2)
  | (get_posix_attr_group_w(dentry) << 1)
  | get_posix_attr_group_x(dentry)) << 3);
 /* Other : 0x0007 */
 inode->i_mode |= ((get_posix_attr_group_r(dentry) << 2)
  | (get_posix_attr_group_w(dentry) << 1)
  | get_posix_attr_group_x(dentry));
 /* User & Group ID */
 uid = sbi->options.fs_uid;
 gid = sbi->options.fs_gid;
 if (!uid) uid = -1;
 if (!gid) gid = -1;
 inode->i_uid = (int)get_posix_attr_user_id(dentry) ?  uid : 0;
 inode->i_gid = (int)get_posix_attr_user_id(dentry) ?  gid : 0;

 /* Special file */
 switch (ftype) {
 case DT_BLK:
  inode->i_rdev =
   ((get_posix_attr_drv_major(dentry) << MINORBITS)
   | get_posix_attr_drv_minor(dentry));
  inode->i_mode &= ~S_IFMT;
  inode->i_mode |= S_IFBLK;
  init_special_inode( inode, inode->i_mode, inode->i_rdev );
  break;
 case DT_CHR:
  inode->i_rdev =
   ((get_posix_attr_drv_major(dentry) << MINORBITS)
   | get_posix_attr_drv_minor(dentry));
  inode->i_mode &= ~S_IFMT;
  inode->i_mode |= S_IFCHR;
  init_special_inode( inode, inode->i_mode, inode->i_rdev );
  break;
 case DT_FIFO:
  inode->i_mode &= ~S_IFMT;
  inode->i_mode |= S_IFIFO;
  init_special_inode(inode, inode->i_mode, inode->i_rdev);
  break;
 case DT_SOCK:
  inode->i_mode &= ~S_IFMT;
  inode->i_mode |= S_IFSOCK;
  init_special_inode(inode, inode->i_mode, inode->i_rdev);
  break;
 }
out:
 return;
}

/**
 set_vfat_posix_attr - set posix attributes to VFAT dir entry

  Returns
   0 ... posix_attr are set
  -1 ... posix_attr are not set
 /
int set_vfat_posix_attr(struct msdos_dir_entry *dentry, struct inode *inode)
{
 int     ftype;

 if (!(inode && dentry) || IS_ERR(inode))
  goto not_set;
 if (!MSDOS_SB(inode->i_sb)->options.posix_attr)
  goto not_set;

 /* File type */
 switch (GET_INODE_FILE_TYPE(inode)) {
 case DT_DIR:
  set_fat_attr_dir(dentry, 1);
  /* fall through */
 case DT_REG:
  set_posix_attr_reg_file(dentry, 1);
  break;
 default:
  for(ftype=0; filetype_table[ftype]; ftype++){
   if (filetype_table[ftype] ==
    GET_INODE_FILE_TYPE(inode)){
     break;
   }
  }
  if (!filetype_table[ftype])
   goto not_set;
  /* mark posix attr for special file */
  set_fat_attr_sys(dentry,1);
  set_posix_attr_spec_file(dentry, 1);
  set_posix_attr_file_type(dentry, ftype);
  break;
 }
 /* Permissions for Owner */
 set_posix_attr_owner_r(dentry, GET_INODE_OWNER_R(inode));
 set_posix_attr_owner_w(dentry, GET_INODE_OWNER_W(inode));
 set_posix_attr_owner_x(dentry, GET_INODE_OWNER_X(inode));
 /* Permissions for Group/Others */
 set_posix_attr_group_r(dentry, GET_INODE_GROUP_R(inode));
 set_posix_attr_group_w(dentry, GET_INODE_GROUP_W(inode));
 set_posix_attr_group_x(dentry, GET_INODE_GROUP_X(inode));
 /* User ID */
 set_posix_attr_user_id(dentry, GET_INODE_USER_ID(inode));

 /* Deivce number */
 switch (GET_INODE_FILE_TYPE(inode)) {
 case DT_CHR:
  /* fall through */
 case DT_BLK:
  set_posix_attr_drv_major(dentry, GET_INODE_DRV_MAJOR(inode));
  set_posix_attr_drv_minor(dentry, GET_INODE_DRV_MINOR(inode));
  break;
 }
 return 0;
not_set:
 return -1;
}
 
 static int vfat_revalidate(struct dentry *dentry, struct nameidata *nd)
 {

   goto error;
  }
  inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
 get_vfat_posix_attr(inode, sinfo.de);
  brelse(sinfo.bh);
  if (IS_ERR(inode)) {
   unlock_kernel();

  }
  inode->i_version++;
  inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
 if (MSDOS_SB(sb)->options.posix_attr) {
  inode->i_mode = mode;
  mark_inode_dirty(inode);
 }
  /* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
  dentry->d_time = dentry->d_parent->d_inode->i_version;
  inode->i_version++;
  inode->i_nlink = 2;
  inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
 if (MSDOS_SB(sb)->options.posix_attr) {+  inode->i_mode = (S_IFDIR | (mode & 0x0fff));
  mark_inode_dirty(inode);

 }
  /* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
  dentry->d_time = dentry->d_parent->d_inode->i_version;

  goto out;
 }
 
static
int vfat_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
{
 /* base : vfat_create() */
 struct super_block *sb = dir->i_sb;
 struct inode *inode = NULL;
 struct fat_slot_info sinfo;
 struct timespec ts;
 int err;
 int len;

#define VFAT_POSIX_ATTR_MAXNAME 255

 if (!MSDOS_SB(sb)->options.posix_attr)
  return -EOPNOTSUPP;

 len = strlen (symname) + 1;
 if (len >= VFAT_POSIX_ATTR_MAXNAME) {
  return -ENAMETOOLONG;
 }

 lock_kernel();

 ts = CURRENT_TIME_SEC;
 err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
 if (err)
  goto out;
 dir->i_version++;

 inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
 brelse(sinfo.bh);
 if (IS_ERR(inode)){
  err = PTR_ERR(inode);
  goto out;
 }
 inode->i_version++;
 inode->i_mode = (S_IFLNK | 0777);
 inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
 inode->i_op = &fat_symlink_inode_operations;
 mark_inode_dirty(inode);

 dentry->d_time = dentry->d_parent->d_inode->i_version;
 d_instantiate(dentry,inode);

 err = page_symlink(dentry->d_inode, symname, len);
out:
 unlock_kernel();
 return err;
}

static
int vfat_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
{
 /* base : vfat_create() */
 struct super_block *sb = dir->i_sb;
 struct inode *inode = NULL;
 struct fat_slot_info sinfo;
 struct timespec ts;
 int err;

 if (!MSDOS_SB(sb)->options.posix_attr)
  return -EOPNOTSUPP;

 lock_kernel();

 ts = CURRENT_TIME_SEC;
 err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
 if (err)
  goto out;
 dir->i_version++;

 inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
 brelse(sinfo.bh);
 if (IS_ERR(inode)){
  err = PTR_ERR(inode);
  goto out;
 }
 inode->i_version++;

 inode->i_mode = mode;
 inode->i_rdev = rdev;

 inode->i_mtime = inode->i_atime = inode->i_ctime = ts;
 init_special_inode(inode, mode, rdev);
 mark_inode_dirty(inode);

 dentry->d_time = dentry->d_parent->d_inode->i_version;
 d_instantiate(dentry, inode);

 err = 0;

out:
 unlock_kernel();
 return err;
}
  static struct inode_operations vfat_dir_inode_operations = {
  .create  = vfat_create,
  .lookup  = vfat_lookup,
  .rmdir  = vfat_rmdir,
  .rename  = vfat_rename,
  .setattr = fat_notify_change,
 .symlink = vfat_symlink,
 .mknod  = vfat_mknod,
 };
 
 static int vfat_fill_super(struct super_block *sb, void *data, int silent)


--- orig/include/linux/msdos_fs.h
+++ mod/include/linux/msdos_fs.h

    sys_immutable:1, /* set = system files are immutable */
    dotsOK:1,        /* set = hidden and system files are named '.filename' */
    isvfat:1,        /* 0=no vfat long filename support, 1=vfat support */
   posix_attr:1,       /* 1= posix attribute mapping support */
    utf8:1,   /* Use of UTF8 character set (Default) */
    unicode_xlate:1, /* create escape sequences for unhandled Unicode */
    numtail:1,       /* Does first alias have a numeric '~1' type tail? */

         unsigned int cmd, unsigned long arg);
 extern struct file_operations fat_file_operations;
 extern struct inode_operations fat_file_inode_operations;
extern struct inode_operations fat_symlink_inode_operations;
 extern int fat_notify_change(struct dentry * dentry, struct iattr * attr);
 extern void fat_truncate(struct inode *inode);
 

 extern void fat_date_unix2dos(int unix_date, __le16 *time, __le16 *date);
 extern int fat_sync_bhs(struct buffer_head **bhs, int nr_bhs);
 
  vfat posix attr option "posix_attr" stuffs
 
  FEATURES
  
  Following attributes/modes are supported in posix attribute mapping
  in VFAT media side. That is, for newly created and/or modified files/dirs,
  system can utilize full posix attributes. After umount-mount cycle, system
  can keep following attributes/modes.
    - FileType
   This supports following special files and it's attributes;
    symbolic link, block device node,
    char device node, fifo, socket
   Regular files/dirs also may have POSIX attributes.
    - DeviceFile
   Major and minor number would be held at ctime
   and both values are limited  to 255.
    - Owner's User ID/Group ID
   This can be used to distinguish root and others,
   because this has just one bit width.
   Value of UID/GID for non-root user will be taken from uid/gid
   option on mounting. If nothing is specified, system uses -1 as
   last resort.
    - Permission for Group/Other (rwx)
   Those modes will be kept in ctime_cs.
   Also permission modes for "others" will be
   same as "group", due to lack of fields.
    - Permission for Owner (rwx)
   These modes will be mapped to FAT attributes.
   Just same as mapping under VFAT.
    - Others
   no sticky, setgid nor setuid bits are not supported.
 
 ALGORITHM FOR MAPPING DECISION
    - Regular file/dir
   To distinguish regular files/dirs, look if this fat dir
   entry doesn't have ATTR_SYS, first. If it doesn't have
   ATTR_SYS, then check if TYPE field (MSB 3bits) in ctime_cs
   is equal to 7. If so, this regular file/dir is created and/or
   modified under VFAT with "posix_attr". And posix attribute
   mapping can be take place. Otherwise, conventional VFAT
   attribute mapping is used.
    - Special file
   To distinguish special files, look if this fat dir entry
   has ATTR_SYS, first. If it has ATTR_SYS, then check
   1st. LSB bit in ctime_cs, referred as "special file flag".
   If set,  this file is created under VFAT with "posix_attr".
   Look up TYPE field to decide special file type.
   This special file detection method has some flaw to make
   potential confusion. E.g. some system file created under
  dos/win may be treated as special file.  However in most case,
  user don't create system file under dos/win.
 
 
 FAT DIR ENTRY FIELDS
 
    - ctime_cs
       8bit byte
   7 6 5 4 3 2 1 0
   |===| | | | | |
   TYPE  | | | | +- special file flag (valid if ATTR_SYS)
         | | | +--- User/Group ID(root or others)
         | | +----- !group X
         | +------- !group W
         +--------- !group R
 
     special file flag
    Indicate this entry has posix attribute mapping.
    This field is valid for fat dir entry, which
    have ATTR_SYS.
 
     special file TYPE
    val type on VFS(val) Description
    ------------------------------------------------
    0  (place folder for backward compat)
    1  DT_LNK (10)  symbolic link
    2 DT_BLK (6)  block dev
    3 DT_CHR (4)  char dev
    4 DT_FIFO (1)  fifo
    5 DT_SOCK (12)  socket
   
    7*) (reserved for DT_REG/DT_DIR)
 
    *)Value 7 is reserved for regular file/dir (DT_REG/DT_DIR).
    Normally ctime_cs would have 0-199 value to stand for
    up to 2sec. The value for DT_REG/DT_DIR is selected
    to be over this range to distinguish if file was created
    under POSIX_ATTR or not.
 
    - attr
   FAT attribute (val)  mapped attribute
   ------------------------------------------------
   ATTR_RO  0x01   !owner W
   ATTR_HIDDEN 0x02  !owner R
   ATTR_SYS 0x04
   ATTR_VOLUME 0x08
   ATTR_DIR 0x10  DIR
   ATTR_ARCH 0x20  !owner X
 
    - ctime
    16bit word
   f e d c b a 9 8 7 6 5 4 3 2 1 0
   |=============| |-------------|
     major    minor
 
 /

/* FAT ATTR_SYS */
static inline
int get_fat_attr_sys(struct msdos_dir_entry *de)
{
 return ((de->attr & 0x4)>>2);
}

static inline
void set_fat_attr_sys(struct msdos_dir_entry *de, int val)
{
 de->attr = (((val << 2) & 0x4) | (de->attr & 0xfb));
}

/* FAT ATTR_DIR */
static inline
int get_fat_attr_dir(struct msdos_dir_entry *de)
{
 return ((de->attr & 0x10)>>4);
}

static inline
void set_fat_attr_dir(struct msdos_dir_entry *de, int val)
{
 de->attr = (((val << 4) & 0x10) | (de->attr & 0xef));
}

/* regular file/dir flag */
static inline
int get_posix_attr_reg_file(struct msdos_dir_entry *de)
{
 return ((de->ctime_cs & 0xe0) == 0xe0);
+}

static inline
void set_posix_attr_reg_file(struct msdos_dir_entry *de, int val)
{
 val = val ? 0xe0 : 0;
 de->ctime_cs = (val | (de->ctime_cs & 0x1f));
}

/* special file flag */
static inline
int get_posix_attr_spec_file(struct msdos_dir_entry *de)
{
 return (de->ctime_cs & 0x01);
}

static inline
void set_posix_attr_spec_file(struct msdos_dir_entry *de, int val)
{
 val = val ? 0x01 : 0x00;
 de->ctime_cs = (val | (de->ctime_cs & 0xfe));
}

/* file type */
static inline
int get_posix_attr_file_type(struct msdos_dir_entry *de)
{
 return ((de->ctime_cs & 0xe0) >> 5);
}

static inline
void set_posix_attr_file_type(struct msdos_dir_entry *de, int val)
{
 val = (val & 0x3) << 5;
 de->ctime_cs = (val | (de->ctime_cs & 0x1f));
}

/* owner r */
static inline
int get_posix_attr_owner_r(struct msdos_dir_entry *de)
{
 return (((de->attr & 0x02) >> 1) ^ 1);
}

static inline
void set_posix_attr_owner_r(struct msdos_dir_entry *de, int val)
{
 val = val ? 0 : 0x02;
 de->attr = (val | (de->attr & 0xfd));
}

/* owner w */
static inline
int get_posix_attr_owner_w(struct msdos_dir_entry *de)
{
 return ((de->attr & 0x01) ^ 1);
}

static inline
void set_posix_attr_owner_w(struct msdos_dir_entry *de, int val)
{
 val = val ? 0 : 0x01;
 de->attr = (val | (de->attr & 0xfe));
}

/* owner x */
static inline
int get_posix_attr_owner_x(struct msdos_dir_entry *de)
{
 return (((de->attr & 0x20) >> 5) ^ 1);
}

static inline
void set_posix_attr_owner_x(struct msdos_dir_entry *de, int val)
{
 val = val ? 0 : 0x20;
 de->attr = (val | (de->attr & 0xdf));
}

/* group r */
static inline
int get_posix_attr_group_r(struct msdos_dir_entry *de)
{
 return (((de->ctime_cs & 0x10) >> 4) ^ 1);
}

static inline
void set_posix_attr_group_r(struct msdos_dir_entry *de, int val)
{
 val = val ? 0 : 0x10;
 de->ctime_cs = (val | (de->ctime_cs & 0xef));
}

/* group w */
static inline
int get_posix_attr_group_w(struct msdos_dir_entry *de)
{
 return (((de->ctime_cs & 0x08) >> 3) ^ 1);
}

static inline
void set_posix_attr_group_w(struct msdos_dir_entry *de, int val)
{
 val = val ? 0 : 0x08;
 de->ctime_cs = (val | (de->ctime_cs & 0xf7));
}

/* group x */
static inline
int get_posix_attr_group_x(struct msdos_dir_entry *de)
{
 return (((de->ctime_cs & 0x04) >> 2) ^ 1);
}

static inline
void set_posix_attr_group_x(struct msdos_dir_entry *de, int val)
{
 val = val ? 0 : 0x04;
 de->ctime_cs = (val | (de->ctime_cs & 0xfb));
}

/* user id */
static inline
int get_posix_attr_user_id(struct msdos_dir_entry *de)
{
 return ((de->ctime_cs & 0x02) >> 1);
}

static inline
void set_posix_attr_user_id(struct msdos_dir_entry *de, int val)
{
 val = val ? 0x02 : 0;
 de->ctime_cs = (val | (de->ctime_cs & 0xfd));
}

/* driver major number */
static inline
int get_posix_attr_drv_major(struct msdos_dir_entry *de)
{
 return ((de->ctime & 0xff00) >> 8);
}

static inline
void set_posix_attr_drv_major(struct msdos_dir_entry *de, int val)
{
 val = (val & 0xff) << 8;
 de->ctime = (val | (de->ctime & 0x00ff));
}

/* driver minor number */
static inline
int get_posix_attr_drv_minor(struct msdos_dir_entry *de)
{
 return (de->ctime & 0x00ff);
}

static inline
void set_posix_attr_drv_minor(struct msdos_dir_entry *de, int val)
{
 de->ctime = ((val & 0x00ff) | (de->ctime & 0xff00));
}

#ifdef CONFIG_VFAT_FS
/* fs/vfat/namei.c */
extern int is_vfat_posix_symlink(struct inode *, struct msdos_dir_entry *);
extern int set_vfat_posix_attr(struct msdos_dir_entry *, struct inode *);
#else /* CONFIG_VFAT_FS */
static inline int
is_vfat_posix_symlink(struct inode *inode, struct msdos_dir_entry *de)
{
 return -1;
}

static inline int
set_vfat_posix_attr(struct msdos_dir_entry *de, struct inode *inode)
{
 return -1;
}
#endif /* CONFIG_VFAT_FS */
 #endif /* __KERNEL__ */

#endif

看下上面的就知道了FAT的文件属性结构等。

基于Jira与Confluence的企业知识库AI助手构建实战 检索增强生成(RAG)技术通过结合信息检索与大型语言模型,有效解决了AI在专业领域知识不足的问题。其核心原理是将外部知识库(如企业文档)进行向量化存储,在用户提问时进行语义检索,并将相关上下文注入提示词中,从而生成精准、有据可依的回答。这一技术架构在工程实践中价值显著,它无需重新训练模型即可让AI掌握特定领域的专业知识,大幅提升了回答的准确性与实用性。典型的应用场景包括智能客服、企业内部知识问答以及代码辅助等。本文以开源项目`dev-kostiuk/jira-confluence-ai-context`为例 阅读详情

相关推荐

超详细YOLOv8目标检测全程概述:环境、训练、验证与预测详解

这篇博文提供了一个关于使用YOLOv8进行目标检测的全面指南,包括环境搭建、模型训练、验证和预测的详细步骤,以及如何解释训练过程中生成的各种图表和数据。整篇文章为读者提供了一个关于如何利用YOLOv8进行目标检测的实践指南,从环境搭建到模型部署,再到结果分析,每一部分都给出了详细的步骤和解释。此外,还有对于模型输出的解释,帮助读者更好地理解和使用YOLOv8模型。

CDBmax的博客 10万+

linux IO操作之获取指定路径下文件数目

初学Linux·IO

x_201_x的博客 1480

手把手教你用Vivado配置Xilinx SEM IP 3.1(附Tera Term串口调试全流程)

本文详细介绍了如何使用Vivado配置Xilinx SEM IP 3.1,包括工程创建、IP参数调整、VIO工具应用以及Tera Term串口调试的全流程。通过手把手教程,帮助开发者快速掌握SEM IP的配置方法,实现存储器软错误的检测与纠正,提升FPGA开发效率。

weixin_30216561的博客 375

linux系统目录操作接口

linux 中使用 DIR 结构体来描述一个已经打开的目录,至于结构体中有什么具体的内容,我们不需要关心,只需要知道 DIR 类型的指针可以表示一个已经打开的目录就可以了。读取 DIR 指向的目录中的文件项,通过返回值返回出文件信息,每一次调用 readdir都会让 DIR 指针指向该目录的下一个文件的位置。打开文件描述符为 fd 的目录,返回一个 DIR 类型指针,DIR 是用来描述打开目录信息的结构体。打开名为 name 的目录,返回一个 DIR 类型指针,DIR 是用来描述打开目录信息的结构体。

jiu_yue_ya的博客 537

ADS 2023 实战:手把手教你仿真一个中心频率 2.4GHz 的带通滤波器(附工程文件)

本文详细介绍了使用ADS 2023软件设计和仿真中心频率2.4GHz带通滤波器的全流程,包括工程准备、指标定义、原理图设计、仿真优化及实际电路实现。通过切比雪夫滤波器拓扑和参数优化,实现高性能的带通滤波器设计,适用于无线通信系统。附有工程文件和常见问题解决方案,助力工程师快速掌握射频滤波器设计技巧。

weixin_30790841的博客 485

AD24-层次原理图的设计

4)在原理图关联对话框中双击需要放置方块图的子图,即激活方块图的放置,单击母图的空白处进行放置。3)设计-Create Sheet From Sheet,进入原理图关联对话框。4)放置-添加图纸入口,放置方块图的内部I/O端口并进行名称更改。2)放置-页面符,放置页面符,并执行Table完成属性设置。5)执行Ctrl+W,端口和内部I/O端口对应连接。1)创建一个工程并完成子图的每页原理图的设计。1)新建项目,创建Main原理图页。3)放置-的端口,放置方块图的端口。以上,就是层次原理图页的设计。

qq_52761962的博客 4955

opendir和readdir

是C标准库的函数,而不是底层的系统调用。系统调用通常提供更底层的操作,而这些库函数是在系统调用的基础上构建的。在不同的操作系统上,这些库函数可能会有所不同,但它们的基本功能相似。是用于文件和目录操作的C标准库函数,而不是系统调用。它们用于在C/C++程序中访问文件系统中的目录和文件。用于打开一个目录,并返回一个指向目录的指针(称为目录流)。这些函数通常与其他文件和目录操作函数一起使用,例如。用于获取文件信息,以便进一步处理文件。用于读取目录中的条目(包括子目录和文件)。

leimeili的博客 3108

汽车零部件智能装配:C#+YOLOv8实现螺栓漏装检测与齿轮错位识别(附PLC通信与机械臂控制)

YOLOv8:小目标检测的最优解相比YOLOv7,YOLOv8的C2f特征融合网络对小目标(5-10mm螺栓)检测精度提升12%,且推理速度快8%;支持大输入尺寸(不显著增加耗时),可放大螺栓细节;官方提供yolov8n.pt(nano版),在边缘计算盒上能跑40+FPS,满足实时性。C#:工业软件的“兼容性核心”主流PLC(西门子S7-1200/1500)、机械臂(ABB、KUKA)的SDK多基于.NET开发,C#可直接调用,避免跨语言通信延迟;多线程管理成熟(Task。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1152

对目录的操作(opendir)

对目录的操作(opendir), 详细介绍了目录的具体功能参数返回值,以及各种举例说明。

a2998658795的博客 6610

解决mmdet3d安装中因PyTorch高版本引发的THC.h缺失问题

本文详细分析了在安装mmdet3d时,因PyTorch版本过高导致THC.h头文件缺失的常见报错问题。文章指出该错误的本质是PyTorch 1.7+版本废弃了旧API,与老版本C++扩展代码不兼容。提供了两种核心解决方案:一是降级PyTorch至1.6及以下版本;二是修改源码,将THC.h引用替换为ATen/cuda等新头文件,并给出了具体的代码修改示例和排查技巧。

weixin_29085151的博客 388

MOSS-TTS开源语音合成家族:从架构解析到生产部署实战

语音合成(TTS)技术旨在让计算机将文本转换为自然流畅的语音,其核心原理通常涉及文本分析、声学模型和声码器等模块。近年来,基于深度学习的端到端TTS模型,特别是结合残差向量量化(RVQ)和Transformer架构的方案,显著提升了合成语音的自然度和效率。这类技术的价值在于能够广泛应用于有声内容创作、智能助手、无障碍服务以及实时交互等场景。本文聚焦于开源的MOSS-TTS家族,它通过模块化设计,针对高保真合成、多角色对话、实时交互等不同需求提供了专用模型。文章深入解析了其底层的Delay与Local两种架构

weixin_28745565的博客 432

C语言--目录读取文件,opendir函数和readdir函数

1,opendir 和 readdir函数 DIR *opendir(const char *name); 返回值:The opendir() and fdopendir() functions return a pointer to the directory stream. 解释:成功返回指向目录流的指针(DIR),失败 返回NULL并设置errno st...

噗呲_DayBreak 6876

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之BswM模块配置详解(上)

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之BswM模块配置详解(上)

weixin_42412049的博客 747

在VC++环境下对文件属性的获取与更改

摘要:本文讲述了在Visual C++ 下编程实现对磁盘文件的属性进行获取以及更改的一般方法,并给出部分相关的关键代码。  一、 引言   文件是数据在磁盘上最常用的一种存放形式,也是在程序设计中与之经常打交道的一种编程对象,不少程序尤其是数据传输和处理类的应用程序更是需要频繁的创建、读取和写入文件。对于一些要求不是很严格的程序,我们往往只关心文件的内容是否正确、文件大小是否有增减或是再严格一些,...

醉逍遥的博客 909

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

如何显示或更改文件属性

不过,需要在文件资源管理器中设置“显示隐藏的文件、文件夹和驱动器”才能看到隐藏的文件(可通过“文件夹选项”对话框设置,在“查看”选项卡中进行操作)。- 常规方法:选中文件后,选择“文件”>“显示简介”,或者使用快捷键Command + I,打开文件简介窗口,其中显示了文件的种类、大小、位置、创建时间、修改时间、标签等属性。例如,可以设置文件的存档属性,用于备份程序识别文件是否已备份;- 锁定属性:在文件简介窗口中有一个“已锁定”复选框,勾选此框后,文件将被锁定,不能进行删除、重命名等操作,除非解锁。

2401_88538178的博客 6199

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

C++更改文件属性

C++更改文件属性可以采用两种办法,一种是通过system()函数,另一种是通过SetFileAttributes()函数。 1.通过system() 通过这个函数可以调用系统命令来操作,用它来调用ATTRIB命令来操作。 这就是这个命令的使用方法,可以通过system()来调用它来操作。 举例 #include <stdlib.h> int main() { system("ATTRIB +r +S +h C:\\1.jpg"); return 0; } 2.通过Se...

zzxhh628的博客 4117

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

在VC++下对文件属性的获取与更改

 在VC++下对文件属性的获取与更改摘要:本文讲述了在Visual C++ 下编程实现对磁盘文件的属性进行获取以及更改的一般方法,并给出部分相关的关键代码。  一、 引言    文件是数据在磁盘上最常用的一种存放形式,也是在程序设计中与之经常打交道的一种编程对象,不少程序尤其是数据传输和处理类的应用程序更是需要频繁的创 建、读取和写入文件。对于一些要求不是很严格的程序,我们往往只关心文件的内容是否

xujianxin's CSDN Blog 882

文件属性信息的获取与更改 WIN32_FIND_DATA

文件属性信息的获取与更改 关于文件的全部属性信息。总计有以下以下9种:文件的标题名、文件的属性(只读、存档,隐藏等)、文件的创建时间、文件的最后访问时间、文件的最后修改时间、文件大小的高位双字、文件大小的低位双字、保留、保留。在这里只有文件标题名和文件的长度可以通过CFile类比较方便的获得,而对于其他几种属性的获取和设置就无能为力了。 在用findfirs

lcjwxd的专栏 2254

linux设置文件属性命令,linux学习笔记——文件属性、文件权限及更改命令

#########################################################################################第六单元#########################################################################################################1....

weixin_32461163的博客 554

Linux文件基本属性及更改文件属性和权限

Linux文件基本属性及更改文件属性和权限,Linux 系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限。为了保护系统的安全性,Linux 系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定。在 Linux 中我们通常使用以下两个命令来修改文件或目录的所属用户与权限:在 Linux 中我们可以使用 ll 或者 ls –l 命令来显示一个文件的属性以及文件所属的用户和组......

weixin_51405802的博客 3296

【Linux学习】常用的基本命令(二)更改文件属性

一、文章描述: Linux基本命令的学习(二):更改文件属性相关的基本命令,基本命令的解释与Xshell演示 总结 二、常用的基本命令(二):更改文件属性 chgrp(change group)更改文件属组 chgrp + 属组名 + 文件名:更改该文件的属组。 chgrp相关的参数: -R 递归处理,将指定目录下的所有文件及子目录一并处理。 … chown(change own)更改文件属主 chown + 属主名 + 文件名:更改该文件的属组 chown相关的参数: -c

翱翔于世纪的博客 714

linux ia文件属性,Linux系统中更改文件属性的Chattr命令,附Chattr语法和示例

本文介绍如何使用chattr命令来更改Linux文件系统上的文件属性,附Chattr语法和示例介绍。前言在Linux操作系统中,文件属性是描述文件行为的元数据属性,例如,属性可以指示是否压缩文件或指定是否可以删除文件。可以设置或清除诸如不变性之类的某些属性,而诸如加密之类的其他属性则是只读的,并且只能查看,对某些属性的支持取决于所使用的文件系统。chattr语法chattr命令采用以下一般形式:c...

weixin_35720882的博客 914

linux更改权限_十分钟读懂Linux文件属性及权限「过来人建议必须掌握」

Linux 文件基本属性Linux系统是一种典型的多用户系统,不同的用户处于不同的地位,拥有不同的权限。为了保护系统的安全性,Linux系统对不同的用户访问同一文件(包括目录文件)的权限做了不同的规定。在Linux中我们可以使用ll或者ls –l命令来显示一个文件的属性以及文件所属的用户和组,如:[root@www /]# ls -ltotal 64dr-xr-xr-x 2 root root 4...

weixin_35947010的博客 127

linux中更改权限的代码,linux学习笔记——文件属性、文件权限及更改命令(示例代码)...

#########################################################################################第六单元#########################################################################################################1....

weixin_39556590的博客 165
上一篇: 好书_usb2.0
下一篇: 创建自己的cocoa framework。
nitghost
博客等级 码龄19年 32粉丝 111原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址