From: David van Moolenbroek Date: Thu, 15 Apr 2010 16:10:28 +0000 (+0000) Subject: fix mfs/isofs signal handling X-Git-Tag: v3.1.7~138 X-Git-Url: http://zhaoyanbai.com/repos/%22../static/icons/ChangeLog.html?a=commitdiff_plain;h=cfb108afc7a7554994a1aa2dd798f509024aabe5;p=minix.git fix mfs/isofs signal handling --- diff --git a/servers/iso9660fs/glo.h b/servers/iso9660fs/glo.h index 5c93a5987..400f128cb 100644 --- a/servers/iso9660fs/glo.h +++ b/servers/iso9660fs/glo.h @@ -28,6 +28,8 @@ EXTERN char user_path[PATH_MAX+1]; /* pathname to be processed */ EXTERN char *vfs_slink_storage; EXTERN int symloop; +EXTERN int unmountdone; + EXTERN dev_t fs_dev; /* the device that is handled by this FS proc */ EXTERN char fs_dev_label[16]; /* Name of the device driver that is handled */ diff --git a/servers/iso9660fs/main.c b/servers/iso9660fs/main.c index c1c18270d..3438771d4 100644 --- a/servers/iso9660fs/main.c +++ b/servers/iso9660fs/main.c @@ -14,6 +14,7 @@ FORWARD _PROTOTYPE(void get_work, (message *m_in) ); /* SEF functions and variables. */ FORWARD _PROTOTYPE( void sef_local_startup, (void) ); FORWARD _PROTOTYPE( int sef_cb_init_fresh, (int type, sef_init_info_t *info) ); +FORWARD _PROTOTYPE( void sef_cb_signal_handler, (int signo) ); /*===========================================================================* * main * @@ -71,6 +72,9 @@ PRIVATE void sef_local_startup() /* No live update support for now. */ + /* Register signal callbacks. */ + sef_setcb_signal_handler(sef_cb_signal_handler); + /* Let SEF perform startup. */ sef_startup(); } @@ -100,6 +104,22 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info) return(OK); } +/*===========================================================================* + * sef_cb_signal_handler * + *===========================================================================*/ +PRIVATE void sef_cb_signal_handler(int signo) +{ + /* Only check for termination signal, ignore anything else. */ + if (signo != SIGTERM) return; + + /* No need to do a sync, as this is a read-only file system. */ + + /* If the file system has already been unmounted, exit immediately. + * We might not get another message. + */ + if (unmountdone) exit(0); +} + /*===========================================================================* * get_work * *===========================================================================*/ diff --git a/servers/iso9660fs/mount.c b/servers/iso9660fs/mount.c index 7df01b784..b9842fdd0 100644 --- a/servers/iso9660fs/mount.c +++ b/servers/iso9660fs/mount.c @@ -101,6 +101,7 @@ PUBLIC int fs_mountpoint() PUBLIC int fs_unmount(void) { release_v_pri(&v_pri); /* Release the super block */ dev_close(driver_endpoints[(fs_dev >> MAJOR) & BYTE].driver_e, fs_dev); + unmountdone = TRUE; return(OK); } diff --git a/servers/mfs/main.c b/servers/mfs/main.c index 5acc79658..d36b5f669 100644 --- a/servers/mfs/main.c +++ b/servers/mfs/main.c @@ -133,6 +133,11 @@ PRIVATE void sef_cb_signal_handler(int signo) exitsignaled = 1; fs_sync(); + + /* If unmounting has already been performed, exit immediately. + * We might not get another message. + */ + if (unmountdone) exit(0); } /*===========================================================================*