5 static int fs_ipc_status
;
8 #define PUFFS_MAX_ARGS 20
10 /*===========================================================================*
12 *===========================================================================*/
13 static int sef_cb_init_fresh(int type
, sef_init_info_t
*info
)
15 /* Initialize the Minix file server. */
19 /*===========================================================================*
20 * sef_cb_signal_handler *
21 *===========================================================================*/
22 static void sef_cb_signal_handler(int signo
)
24 /* Only check for termination signal, ignore anything else. */
25 if (signo
!= SIGTERM
) return;
34 /*===========================================================================*
36 *===========================================================================*/
37 static void sef_local_startup(void)
39 /* Register init callbacks. */
40 sef_setcb_init_fresh(sef_cb_init_fresh
);
42 /* Register signal callbacks. */
43 sef_setcb_signal_handler(sef_cb_signal_handler
);
45 /* Let SEF perform startup. */
49 /*===========================================================================*
51 *===========================================================================*/
52 static int get_work(message
*msg
, int *ipc_status
)
57 if ((r
= sef_receive_status(ANY
, msg
, ipc_status
)) != OK
) {
58 if (r
== EINTR
) /* sef_cancel from signal handler? */
59 break; /* see if we can exit the main loop */
60 panic("sef_receive failed: %d", r
);
62 if (msg
->m_source
== VFS_PROC_NR
)
64 lpuffs_debug("libpuffs: unexpected source %d\n", msg
->m_source
);
70 int __wrap_main(int argc
, char *argv
[]);
71 int __real_main(int argc
, char* argv
[]);
73 int __wrap_main(int argc
, char *argv
[])
77 static char* new_argv
[PUFFS_MAX_ARGS
];
80 /* SEF local startup. */
81 env_setargs(argc
, argv
);
84 global_kcred
.pkcr_type
= PUFFCRED_TYPE_INTERNAL
;
87 panic("Unexpected arguments, use:\
88 mount -t fs /dev/ /dir [-o option1,option2]\n");
91 name
= argv
[0] + strlen(argv
[0]);
92 while (*name
!= '/' && name
!= argv
[0])
96 strcpy(fs_name
, name
);
98 new_argv
[new_argc
] = argv
[0];
101 for (i
= 1; i
< argc
; i
++) {
102 if (new_argc
>= PUFFS_MAX_ARGS
) {
103 panic("Too many arguments, change PUFFS_MAX_ARGS");
105 new_argv
[new_argc
] = argv
[i
];
109 assert(new_argc
> 0);
111 /* Get the mount request from VFS, so we can deal with it later. */
112 (void)get_work(&fs_msg
, &fs_ipc_status
);
115 return __real_main(new_argc
, new_argv
);
119 * Receive a message unless one was already pending. Process the message, and
120 * send a reply if necessary. Return whether puffs should keep running.
126 if (fs_pending
== TRUE
|| get_work(&fs_msg
, &fs_ipc_status
) == OK
) {
129 fsdriver_process(&puffs_table
, &fs_msg
, fs_ipc_status
, FALSE
);
132 return mounted
|| !exitsignaled
;
136 * Initialize MINIX3-specific settings.
139 lpuffs_init(struct puffs_usermount
* pu
)
142 buildpath
= pu
->pu_flags
& PUFFS_FLAG_BUILDPATH
; /* XXX */
144 LIST_INIT(&pu
->pu_pnode_removed_lst
);