Documentation/filesystems/autofs.rst

Source file repositories/reference/linux-study-clean/Documentation/filesystems/autofs.rst

File Facts

System
Linux kernel
Corpus path
Documentation/filesystems/autofs.rst
Extension
.rst
Size
25088 bytes
Lines
581
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct autofs_v5_packet {
		struct autofs_packet_hdr hdr;
		autofs_wqt_t wait_queue_token;
		__u32 dev;
		__u64 ino;
		__u32 uid;
		__u32 gid;
		__u32 pid;
		__u32 tgid;
		__u32 len;
		char name[NAME_MAX+1];
        };

And the format of the header is::

	struct autofs_packet_hdr {
		int proto_version;		/* Protocol version */
		int type;			/* Type of packet */
	};

where the type is one of ::

	autofs_ptype_missing_indirect
	autofs_ptype_expire_indirect
	autofs_ptype_missing_direct
	autofs_ptype_expire_direct

so messages can indicate that a name is missing (something tried to
access it but it isn't there) or that it has been selected for expiry.

The pipe will be set to "packet mode" (equivalent to passing
`O_DIRECT`) to _pipe2(2)_ so that a read from the pipe will return at
most one packet, and any unread portion of a packet will be discarded.

The `wait_queue_token` is a unique number which can identify a
particular request to be acknowledged.  When a message is sent over
the pipe the affected dentry is marked as either "active" or
"expiring" and other accesses to it block until the message is
acknowledged using one of the ioctls below with the relevant
`wait_queue_token`.

Communicating with autofs: root directory ioctls
================================================

The root directory of an autofs filesystem will respond to a number of
ioctls.  The process issuing the ioctl must have the CAP_SYS_ADMIN
capability, or must be the automount daemon.

The available ioctl commands are:

- **AUTOFS_IOC_READY**:
	a notification has been handled.  The argument
	to the ioctl command is the "wait_queue_token" number
	corresponding to the notification being acknowledged.
- **AUTOFS_IOC_FAIL**:
	similar to above, but indicates failure with
	the error code `ENOENT`.
- **AUTOFS_IOC_CATATONIC**:
	Causes the autofs to enter "catatonic"
	mode meaning that it stops sending notifications to the daemon.
	This mode is also entered if a write to the pipe fails.
- **AUTOFS_IOC_PROTOVER**:
	This returns the protocol version in use.
- **AUTOFS_IOC_PROTOSUBVER**:
	Returns the protocol sub-version which
	is really a version number for the implementation.
- **AUTOFS_IOC_SETTIMEOUT**:
	This passes a pointer to an unsigned
	long.  The value is used to set the timeout for expiry, and
	the current timeout value is stored back through the pointer.

Annotation

Implementation Notes