diff options
Diffstat (limited to 'man2/ioctl_fat.2')
-rw-r--r-- | man2/ioctl_fat.2 | 85 |
1 files changed, 42 insertions, 43 deletions
diff --git a/man2/ioctl_fat.2 b/man2/ioctl_fat.2 index 72393555f..67b5a2c04 100644 --- a/man2/ioctl_fat.2 +++ b/man2/ioctl_fat.2 @@ -1,7 +1,7 @@ .\" Copyright (C) 2014, Heinrich Schuchardt <xypron.glpk@gmx.de> .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft -.TH ioctl_fat 2 2023-02-10 "Linux man-pages 6.03" +.TH ioctl_fat 2 2023-05-03 "Linux man-pages 6.05.01" .SH NAME ioctl_fat \- manipulating the FAT filesystem .SH LIBRARY @@ -208,25 +208,24 @@ does not refer to an object in a FAT filesystem. .PP For further error values, see .BR ioctl (2). -.SH VERSIONS +.SH STANDARDS +Linux. +.SH HISTORY +.TP .B VFAT_IOCTL_READDIR_BOTH -and +.TQ .B VFAT_IOCTL_READDIR_SHORT -first appeared in Linux 2.0. -.PP +Linux 2.0. +.TP .B FAT_IOCTL_GET_ATTRIBUTES -and +.TQ .B FAT_IOCTL_SET_ATTRIBUTES -first appeared .\" just before we got Git history -in Linux 2.6.12. -.PP +Linux 2.6.12. +.TP .B FAT_IOCTL_GET_VOLUME_ID -was introduced in version 3.11 +Linux 3.11. .\" commit 6e5b93ee55d401f1619092fb675b57c28c9ed7ec -of the Linux kernel. -.SH STANDARDS -This API is Linux-specific. .SH EXAMPLES .SS Toggling the archive flag The following program demonstrates the usage of @@ -258,7 +257,7 @@ Archive flag is not set #include <stdlib.h> #include <sys/ioctl.h> #include <unistd.h> - +\& /* * Read file attributes of a file on a FAT filesystem. * Output the state of the archive flag. @@ -268,50 +267,50 @@ readattr(int fd) { int ret; uint32_t attr; - +\& ret = ioctl(fd, FAT_IOCTL_GET_ATTRIBUTES, &attr); if (ret == \-1) { perror("ioctl"); exit(EXIT_FAILURE); } - +\& if (attr & ATTR_ARCH) printf("Archive flag is set\en"); else printf("Archive flag is not set\en"); - +\& return attr; } - +\& int main(int argc, char *argv[]) { int fd; int ret; uint32_t attr; - +\& if (argc != 2) { printf("Usage: %s FILENAME\en", argv[0]); exit(EXIT_FAILURE); } - +\& fd = open(argv[1], O_RDONLY); if (fd == \-1) { perror("open"); exit(EXIT_FAILURE); } - +\& /* * Read and display the FAT file attributes. */ attr = readattr(fd); - +\& /* * Invert archive attribute. */ printf("Toggling archive flag\en"); attr \[ha]= ATTR_ARCH; - +\& /* * Write the changed FAT file attributes. */ @@ -320,14 +319,14 @@ main(int argc, char *argv[]) perror("ioctl"); exit(EXIT_FAILURE); } - +\& /* * Read and display the FAT file attributes. */ readattr(fd); - +\& close(fd); - +\& exit(EXIT_SUCCESS); } .EE @@ -358,25 +357,25 @@ Volume ID 6443\-6241 #include <stdlib.h> #include <sys/ioctl.h> #include <unistd.h> - +\& int main(int argc, char *argv[]) { int fd; int ret; uint32_t id; - +\& if (argc != 2) { printf("Usage: %s FILENAME\en", argv[0]); exit(EXIT_FAILURE); } - +\& fd = open(argv[1], O_RDONLY); if (fd == \-1) { perror("open"); exit(EXIT_FAILURE); } - +\& /* * Read volume ID. */ @@ -385,14 +384,14 @@ main(int argc, char *argv[]) perror("ioctl"); exit(EXIT_FAILURE); } - +\& /* * Format the output as two groups of 16 bits each. */ printf("Volume ID %04x\-%04x\en", id >> 16, id & 0xFFFF); - +\& close(fd); - +\& exit(EXIT_SUCCESS); } .EE @@ -426,19 +425,19 @@ LOWER.TXT \-> \[aq]lower.txt\[aq] #include <stdlib.h> #include <sys/ioctl.h> #include <unistd.h> - +\& int main(int argc, char *argv[]) { int fd; int ret; struct __fat_dirent entry[2]; - +\& if (argc != 2) { printf("Usage: %s DIRECTORY\en", argv[0]); exit(EXIT_FAILURE); } - +\& /* * Open file descriptor for the directory. */ @@ -447,14 +446,14 @@ main(int argc, char *argv[]) perror("open"); exit(EXIT_FAILURE); } - +\& for (;;) { - +\& /* * Read next directory entry. */ ret = ioctl(fd, VFAT_IOCTL_READDIR_BOTH, entry); - +\& /* * If an error occurs, the return value is \-1. * If the end of the directory list has been reached, @@ -464,23 +463,23 @@ main(int argc, char *argv[]) */ if (ret < 1) break; - +\& /* * Write both the short name and the long name. */ printf("%s \-> \[aq]%s\[aq]\en", entry[0].d_name, entry[1].d_name); } - +\& if (ret == \-1) { perror("VFAT_IOCTL_READDIR_BOTH"); exit(EXIT_FAILURE); } - +\& /* * Close the file descriptor. */ close(fd); - +\& exit(EXIT_SUCCESS); } .EE |