[systemd-devel] About autofs: no handling of expire??

Lennart Poettering lennart at poettering.net
Wed May 2 03:39:34 PDT 2012


On Wed, 02.05.12 07:45, Stef Bon (stefbon at gmail.com) wrote:

> Hi,
> 
> I've been looking into the code how systemd handles the automounting.

Heya,

> I've got two issues:
> 
> a. I've found the handling of the "missing" packet
> (autofs_ptype_missing_direct), which triggers the
> mounting. But I did not found the handling of the expire packet
> (autofs_ptype_expire_direct). Is this on purpose?
> I see a timeout set, so I guess it was the intention to handle the
> expire.

We currently don't do expiration, since this wasn't intended as a full
autofs implementation, but just a way to parallelize and delay load
things at boot.

That said, we could support expire easily I guess, and so I have now
added this to the TODO list.

> b. the packet read from the pipe is of type union
> autofs_v5_packet_union which looks like:
> 
> union autofs_v5_packet_union {
>         struct autofs_packet_hdr hdr;
>         struct autofs_v5_packet v5_packet;
>         autofs_packet_missing_indirect_t missing_indirect;
>         autofs_packet_expire_indirect_t expire_indirect;
>         autofs_packet_missing_direct_t missing_direct;
>         autofs_packet_expire_direct_t expire_direct;
> };
> 
> where autofs_v5_packet is:
> 
> 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];
> };
> 
> now in the code of automount_fd_event, the selection is based upon
> packet.hdr.type, and futher the fields
> packet.v5_packet.pid are used. Now this while packet is an union: it's
> used as hdr OR as autofs_v5_packet, not both at the same time.
> It works, so here probably happens something strange: while using the
> field packet.hdr, actually the field packet.v5_packet.hdr is used. Is
> this correct?

In Autofs5 all packets have the same format which exposes
pid. i.e. autofs_packet_xxx_yyy_t are all typedef'ed to the same packet
struct. Hence accessing this this way is safe.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list