mirror of https://github.com/mkerrisk/man-pages
ioctl_fat.2: Tweaks to Heinrich's new page
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
parent
68232827ac
commit
f54da10e44
|
@ -23,24 +23,24 @@
|
||||||
.\" %%%LICENSE_END
|
.\" %%%LICENSE_END
|
||||||
.TH IOCTl-FAT 2 2015-01-23 "Linux" "Linux Programmer's Manual"
|
.TH IOCTl-FAT 2 2015-01-23 "Linux" "Linux Programmer's Manual"
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
ioctl-fat \- manipulating the FAT filesystem
|
ioctl_fat \- manipulating the FAT filesystem
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.nf
|
.nf
|
||||||
.B #include <linux/msdos_fs.h>
|
.B #include <linux/msdos_fs.h>
|
||||||
.br
|
.br
|
||||||
.B #include <sys/ioctl.h>
|
.B #include <sys/ioctl.h>
|
||||||
.sp
|
.sp
|
||||||
.BI "int ioctl(int " fd ", FAT_IOCTL_GET_ATTRIBUTES, uint32_t * " attr);
|
.BI "int ioctl(int " fd ", FAT_IOCTL_GET_ATTRIBUTES, uint32_t * " attr );
|
||||||
.BI "int ioctl(int " fd ", FAT_IOCTL_SET_ATTRIBUTES, uint32_t * " attr);
|
.BI "int ioctl(int " fd ", FAT_IOCTL_SET_ATTRIBUTES, uint32_t * " attr );
|
||||||
.BI "int ioctl(int " fd ", FAT_IOCTL_GET_VOLUME_ID, uint32_t * " id);
|
.BI "int ioctl(int " fd ", FAT_IOCTL_GET_VOLUME_ID, uint32_t * " id );
|
||||||
.BI "int ioctl(int " fd ", VFAT_IOCTL_READDIR_BOTH,
|
.BI "int ioctl(int " fd ", VFAT_IOCTL_READDIR_BOTH,
|
||||||
.BI " struct __fat_dirent[2] " entry);
|
.BI " struct __fat_dirent[2] " entry );
|
||||||
.BI "int ioctl(int " fd ", VFAT_IOCTL_READDIR_SHORT,
|
.BI "int ioctl(int " fd ", VFAT_IOCTL_READDIR_SHORT,
|
||||||
.BI " struct __fat_dirent[2] " entry);
|
.BI " struct __fat_dirent[2] " entry );
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
The
|
The
|
||||||
.BR ioctl (2)
|
.BR ioctl (2)
|
||||||
function can be used to read and write metadata of the FAT filesystems that
|
system call can be used to read and write metadata of FAT filesystems that
|
||||||
are not accessible using other system calls.
|
are not accessible using other system calls.
|
||||||
.SS Reading and setting file attributes
|
.SS Reading and setting file attributes
|
||||||
Files and directories in the FAT filesystem possess an attribute bit mask that
|
Files and directories in the FAT filesystem possess an attribute bit mask that
|
||||||
|
@ -51,7 +51,7 @@ and written with
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.I fd
|
.I fd
|
||||||
argument contains a file descriptor for the file or directory.
|
argument contains a file descriptor for a file or directory.
|
||||||
It is sufficient to create the file descriptor by calling
|
It is sufficient to create the file descriptor by calling
|
||||||
.BR open (2)
|
.BR open (2)
|
||||||
with the
|
with the
|
||||||
|
@ -60,8 +60,8 @@ flag.
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.I attr
|
.I attr
|
||||||
argument contains a pointer to the bit mask.
|
argument contains a pointer to a bit mask.
|
||||||
The bits of the bit mask are
|
The bits of the bit mask are:
|
||||||
.TP
|
.TP
|
||||||
.B ATTR_RO
|
.B ATTR_RO
|
||||||
This bit specifies that the file or directory is read-only.
|
This bit specifies that the file or directory is read-only.
|
||||||
|
@ -89,7 +89,7 @@ The zero value
|
||||||
.B ATTR_NONE
|
.B ATTR_NONE
|
||||||
can be used to indicate that no attribute bit is set.
|
can be used to indicate that no attribute bit is set.
|
||||||
.SS Reading the volume label
|
.SS Reading the volume label
|
||||||
Fat filesystems are identified by a volume label.
|
FAT filesystems are identified by a volume label.
|
||||||
The volume label can be read with
|
The volume label can be read with
|
||||||
.BR FAT_IOCTL_GET_VOLUME_ID .
|
.BR FAT_IOCTL_GET_VOLUME_ID .
|
||||||
.PP
|
.PP
|
||||||
|
@ -107,7 +107,7 @@ The
|
||||||
.I id
|
.I id
|
||||||
argument is a pointer to the field that will be filled with the volume ID.
|
argument is a pointer to the field that will be filled with the volume ID.
|
||||||
Typically the volume label is displayed to the user as a group of two
|
Typically the volume label is displayed to the user as a group of two
|
||||||
16-bit fields.
|
16-bit fields:
|
||||||
.PP
|
.PP
|
||||||
.in +4n
|
.in +4n
|
||||||
.nf
|
.nf
|
||||||
|
@ -134,14 +134,14 @@ It is sufficient to create the file descriptor by calling
|
||||||
with the
|
with the
|
||||||
.B O_RDONLY
|
.B O_RDONLY
|
||||||
flag.
|
flag.
|
||||||
The file descriptor can be only used once to iterate over the directory
|
The file descriptor can be used only once to iterate over the directory
|
||||||
entries by calling
|
entries by calling
|
||||||
.BR ioctl (2)
|
.BR ioctl (2)
|
||||||
repeatedly.
|
repeatedly.
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.I entry
|
.I entry
|
||||||
argument is a two-element array of the following structures.
|
argument is a two-element array of the following structures:
|
||||||
|
|
||||||
.in +4n
|
.in +4n
|
||||||
.nf
|
.nf
|
||||||
|
@ -157,14 +157,17 @@ struct __fat_dirent {
|
||||||
The first entry in the array is for the short filename.
|
The first entry in the array is for the short filename.
|
||||||
The second entry is for the long filename.
|
The second entry is for the long filename.
|
||||||
.PP
|
.PP
|
||||||
Field
|
The field
|
||||||
.I d_reclen
|
.I d_reclen
|
||||||
specifies the length of the filename in field
|
contains the length of the filename in the field
|
||||||
.IR d_name .
|
.IR d_name .
|
||||||
A length of 0 for the short filename signals that the end of the directory
|
A length of 0 for the short filename signals that the end of the directory
|
||||||
has been reached.
|
has been reached.
|
||||||
|
.\" FIXME Missing here are explanations of the fileds ;d_ino' and 'd_off'
|
||||||
.SH RETURN VALUE
|
.SH RETURN VALUE
|
||||||
On error, -1 is returned, and errno is set to indicate the error.
|
On error, \-1 is returned, and
|
||||||
|
.I errno
|
||||||
|
is set to indicate the error.
|
||||||
.SH ERRORS
|
.SH ERRORS
|
||||||
.TP
|
.TP
|
||||||
.B ENOTDIR
|
.B ENOTDIR
|
||||||
|
@ -172,16 +175,22 @@ This error is returned by
|
||||||
.B VFAT_IOCTL_READDIR_SHORT
|
.B VFAT_IOCTL_READDIR_SHORT
|
||||||
and
|
and
|
||||||
.B VFAT_IOCTL_READDIR_SHORT
|
.B VFAT_IOCTL_READDIR_SHORT
|
||||||
if the file descriptor does not point to a directory.
|
if
|
||||||
|
.I fd
|
||||||
|
does not refer to a directory.
|
||||||
.TP
|
.TP
|
||||||
.B ENOTTY
|
.B ENOTTY
|
||||||
This error signals that the file descriptor is not for a FAT filesystem.
|
The file descriptor
|
||||||
|
.I fd
|
||||||
|
does not refer to an object in a FAT filesystem.
|
||||||
.PP
|
.PP
|
||||||
For further error values see
|
For further error values, see
|
||||||
.BR ioctl (2).
|
.BR ioctl (2).
|
||||||
.SH VERSIONS
|
.SH VERSIONS
|
||||||
.B FAT_IOCTL_GET_VOLUME_ID
|
.B FAT_IOCTL_GET_VOLUME_ID
|
||||||
was introduced in version 3.11 of the Linux kernel.
|
was introduced in version 3.11
|
||||||
|
.\" commit 6e5b93ee55d401f1619092fb675b57c28c9ed7ec
|
||||||
|
of the Linux kernel.
|
||||||
.PP
|
.PP
|
||||||
.BR FAT_IOCTL_GET_ATTRIBUTES ,
|
.BR FAT_IOCTL_GET_ATTRIBUTES ,
|
||||||
.BR FAT_IOCTL_SET_ATTRIBUTES ,
|
.BR FAT_IOCTL_SET_ATTRIBUTES ,
|
||||||
|
@ -193,14 +202,16 @@ were introduced before version 2.6.28 of the Linux kernel.
|
||||||
This API is Linux-specific.
|
This API is Linux-specific.
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
.SS Toggling the archive flag
|
.SS Toggling the archive flag
|
||||||
The following program demonstrates the usage of the ioctl API to manipulate
|
The following program demonstrates the usage of
|
||||||
file attributes.
|
.BR ioctl ()
|
||||||
It reads and displays the archive attribute of a file.
|
to manipulate file attributes.
|
||||||
After inverting the value of the attribute, it reads and displays it again.
|
The program reads and displays the archive attribute of a file.
|
||||||
|
After inverting the value of the attribute,
|
||||||
|
the program reads and displays the attribute again.
|
||||||
.PP
|
.PP
|
||||||
The following was recorded when applying the program for the file
|
The following was recorded when applying the program for the file
|
||||||
.IR /mnt/user/foo .
|
.IR /mnt/user/foo :
|
||||||
.SS Example output
|
|
||||||
.in +4n
|
.in +4n
|
||||||
.nf
|
.nf
|
||||||
# ./toggle_archive_flag /mnt/user/foo
|
# ./toggle_archive_flag /mnt/user/foo
|
||||||
|
@ -294,13 +305,14 @@ main(int argc, char *argv[])
|
||||||
.fi
|
.fi
|
||||||
.in
|
.in
|
||||||
.SS Reading the volume label
|
.SS Reading the volume label
|
||||||
The following program demonstrates the usage of the ioctl API to
|
The following program demonstrates the use of
|
||||||
display the volume label of a FAT filesystem.
|
.BR ioctl (2)
|
||||||
|
to display the volume label of a FAT filesystem.
|
||||||
.PP
|
.PP
|
||||||
The following output was recorded when applying the program for
|
The following output was recorded when applying the program for
|
||||||
directory
|
directory
|
||||||
.IR /mnt/user .
|
.IR /mnt/user :
|
||||||
.SS Example output
|
|
||||||
.in +4n
|
.in +4n
|
||||||
.nf
|
.nf
|
||||||
$ ./display_volume_id /mnt/user
|
$ ./display_volume_id /mnt/user
|
||||||
|
@ -357,12 +369,13 @@ main(int argc, char *argv[])
|
||||||
.fi
|
.fi
|
||||||
.in
|
.in
|
||||||
.SS Listing a directory
|
.SS Listing a directory
|
||||||
The following program demonstrates the usage of the ioctl API to
|
The following program demonstrates the use of
|
||||||
list a directory.
|
.BR ioctl (2)
|
||||||
|
to list a directory.
|
||||||
.PP
|
.PP
|
||||||
The following was recorded when applying the program for the directory
|
The following was recorded when applying the program to the directory
|
||||||
.IR /mnt/user .
|
.IR /mnt/user :
|
||||||
.SS Example output
|
|
||||||
.in +4n
|
.in +4n
|
||||||
.nf
|
.nf
|
||||||
$ ./fat_dir /mnt/user
|
$ ./fat_dir /mnt/user
|
||||||
|
@ -424,6 +437,7 @@ main(int argc, char *argv[])
|
||||||
*/
|
*/
|
||||||
printf("%s \-> '%s'\\n", entry[0].d_name, entry[1].d_name);
|
printf("%s \-> '%s'\\n", entry[0].d_name, entry[1].d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret == \-1) {
|
if (ret == \-1) {
|
||||||
perror("VFAT_IOCTL_READDIR_BOTH");
|
perror("VFAT_IOCTL_READDIR_BOTH");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
Loading…
Reference in New Issue