如何读取文件的属性VFAT在使用C的Linux [英] How to read vfat attributes of files in Linux using C

查看:186
本文介绍了如何读取文件的属性VFAT在使用C的Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装在Linux下的驱动程序VFAT是FAT文件系统。
我想知道我是如何将能够读取文件的VFAT属性,比如隐藏和只读。

I have a FAT filesystem mounted in Linux with the vfat driver. I want to know how I would be able to read the vfat attributes of a file such as "hidden" and "read-only".


http://www.gnu.org/s/libc/manual/html_node/Attribute-Meanings.html#Attribute-Meanings

它们不包含任何然而VFAT属性。任何人可以帮助?

These don't contain any vfat attributes however. Can anybody help?

谢谢,

Katsupoy

推荐答案

FAT的DOS属性不能很好地映射到UNIX文件系统模型,因此Linux的 VFAT 驱动程序不反映它们。

FAT's DOS attributes do not map well to the UNIX filesystem model, so Linux's vfat driver does not reflect them.

而不是安装文件系统中,使用 mtools的读取用户空间文件系统。

Instead of mounting the filesystem, use mtools to read the filesystem from userspace.


修改我撒谎了。显然, VFAT 驱动程序能够处理这些DOS属性,至少为2.4.29(我想,我的历史日志不回去那么远)<。 / p>

Edit I lied. Apparently the vfat driver is able to deal with these DOS attributes, at least as of 2.4.29 (I think; my historical logs don't go back that far).

#include <inttypes.h>
#include <sys/ioctl.h>
#include <linux/msdos_fs.h>

int fd = open("/mnt/fat/...", ...);
__u32 attrs;
ioctl(fd, FAT_IOCTL_GET_ATTRIBUTES, &attrs);
attrs = ATTR_NONE;  /* ATTR_{RO,HIDDEN,SYS,VOLUME,DIR,ARCH} */
ioctl(fd, FAT_IOCTL_SET_ATTRIBUTES, &attrs);

这篇关于如何读取文件的属性VFAT在使用C的Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆