summaryrefslogtreecommitdiffstats
path: root/man2/ioctl_fat.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/ioctl_fat.2')
-rw-r--r--man2/ioctl_fat.260
1 files changed, 30 insertions, 30 deletions
diff --git a/man2/ioctl_fat.2 b/man2/ioctl_fat.2
index d00855095..64cde8e2c 100644
--- a/man2/ioctl_fat.2
+++ b/man2/ioctl_fat.2
@@ -257,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.
@@ -267,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.
*/
@@ -319,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
@@ -357,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.
*/
@@ -384,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
@@ -425,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.
*/
@@ -446,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,
@@ -463,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