1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
7 #include "load-fragment.h"
8 #include "load-fstab.h"
9 #include "load-dropin.h"
11 static int automount_load(Name
*n
) {
13 Automount
*a
= AUTOMOUNT(n
);
17 exec_context_defaults(&a
->exec_context
);
19 /* Load a .automount file */
20 if ((r
= name_load_fragment(n
)) < 0 && errno
!= -ENOENT
)
23 /* Load entry from /etc/fstab */
24 if ((r
= name_load_fstab(n
)) < 0)
27 /* Load drop-in directory data */
28 if ((r
= name_load_dropin(n
)) < 0)
34 static void automount_dump(Name
*n
, FILE *f
, const char *prefix
) {
36 static const char* const state_table
[_AUTOMOUNT_STATE_MAX
] = {
37 [AUTOMOUNT_DEAD
] = "dead",
38 [AUTOMOUNT_START_PRE
] = "start-pre",
39 [AUTOMOUNT_START_POST
] = "start-post",
40 [AUTOMOUNT_WAITING
] = "waiting",
41 [AUTOMOUNT_RUNNING
] = "running",
42 [AUTOMOUNT_STOP_PRE
] = "stop-pre",
43 [AUTOMOUNT_STOP_POST
] = "stop-post",
44 [AUTOMOUNT_MAINTAINANCE
] = "maintainance"
47 static const char* const command_table
[_AUTOMOUNT_EXEC_MAX
] = {
48 [AUTOMOUNT_EXEC_START_PRE
] = "StartPre",
49 [AUTOMOUNT_EXEC_START_POST
] = "StartPost",
50 [AUTOMOUNT_EXEC_STOP_PRE
] = "StopPre",
51 [AUTOMOUNT_EXEC_STOP_POST
] = "StopPost"
54 AutomountExecCommand c
;
55 Automount
*s
= AUTOMOUNT(n
);
60 "%sAutomount State: %s\n"
62 prefix
, state_table
[s
->state
],
65 exec_context_dump(&s
->exec_context
, f
, prefix
);
67 for (c
= 0; c
< _AUTOMOUNT_EXEC_MAX
; c
++) {
70 LIST_FOREACH(i
, s
->exec_command
[c
])
71 fprintf(f
, "%s%s: %s\n", prefix
, command_table
[c
], i
->path
);
75 static NameActiveState
automount_active_state(Name
*n
) {
77 static const NameActiveState table
[_AUTOMOUNT_STATE_MAX
] = {
78 [AUTOMOUNT_DEAD
] = NAME_INACTIVE
,
79 [AUTOMOUNT_START_PRE
] = NAME_ACTIVATING
,
80 [AUTOMOUNT_START_POST
] = NAME_ACTIVATING
,
81 [AUTOMOUNT_WAITING
] = NAME_ACTIVE
,
82 [AUTOMOUNT_RUNNING
] = NAME_ACTIVE
,
83 [AUTOMOUNT_STOP_PRE
] = NAME_DEACTIVATING
,
84 [AUTOMOUNT_STOP_POST
] = NAME_DEACTIVATING
,
85 [AUTOMOUNT_MAINTAINANCE
] = NAME_INACTIVE
,
88 return table
[AUTOMOUNT(n
)->state
];
91 static void automount_free_hook(Name
*n
) {
92 Automount
*d
= AUTOMOUNT(n
);
98 const NameVTable automount_vtable
= {
101 .load
= automount_load
,
102 .dump
= automount_dump
,
108 .active_state
= automount_active_state
,
110 .free_hook
= automount_free_hook