diff options
author | H. Peter Anvin <hpa@zytor.com> | 2005-02-02 07:21:33 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2005-02-02 07:21:33 +0000 |
commit | 367cb83af1438245766c13478a72c9e9fc3eb8a6 (patch) | |
tree | d664c8cd635b59a7e791910e813f17d882a4999e | |
parent | 5a2ac1d14cb76603e91fdcc6f3b7409964e017d2 (diff) | |
download | fatattr-367cb83af1438245766c13478a72c9e9fc3eb8a6.tar.gz |
Change to 32-bit ioctls.
-rw-r--r-- | fatattr.c | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -31,20 +31,21 @@ #include <linux/msdos_fs.h> #ifndef FAT_IOCTL_GET_ATTRIBUTES -# define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u8) +# define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32) #endif #ifndef FAT_IOCTL_SET_ATTRIBUTES -# define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u8) +# define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32) #endif const char *program; -const char bit_to_char[8] = "rhsvda67"; +/* Currently supports only the FAT flags, not the NTFS ones */ +const char bit_to_char[] = "rhsvda67"; static int -chattr(const char *file, uint8_t s_attr, uint8_t c_attr) +chattr(const char *file, uint32_t s_attr, uint32_t c_attr) { int fd = -1; - uint8_t attr, nattr; + uint32_t attr, nattr; int e; fd = open(file, O_RDONLY); @@ -77,7 +78,7 @@ static int lsattr(const char *file) { int fd = -1; - uint8_t attr; + uint32_t attr; int i, e; fd = open(file, O_RDONLY); @@ -89,7 +90,7 @@ lsattr(const char *file) close(fd); - for ( i = 0 ; i < 8 ; i++ ) { + for ( i = 0 ; bit_to_char[i] ; i++ ) { putchar( (attr & 1) ? bit_to_char[i] : ' ' ); attr >>= 1; } @@ -106,10 +107,10 @@ lsattr(const char *file) return -1; } -static uint8_t +static uint32_t parse_attr(const char *attrs) { - uint8_t attr = 0; + uint32_t attr = 0; const char *p; while ( *attrs ) { @@ -128,14 +129,14 @@ parse_attr(const char *attrs) static void __attribute__((noreturn)) usage(void) { - fprintf(stderr, "Usage: %s [-+rhsa67] files...\n", program); + fprintf(stderr, "Usage: %s [-+%s] files...\n", program, bit_to_char); exit(EX_USAGE); } int main(int argc, char *argv[]) { - uint8_t s_attr = 0; /* Attributes to set */ - uint8_t c_attr = 0; /* Attributes to clear */ + uint32_t s_attr = 0; /* Attributes to set */ + uint32_t c_attr = 0; /* Attributes to clear */ int i; int files = 0; /* Files processed */ int e; |