Index: mount_portal.c =================================================================== RCS file: /home/ncvs/src/sbin/mount_portal/mount_portal.c,v retrieving revision 1.12 diff -c -r1.12 mount_portal.c *** mount_portal.c 1997/03/29 03:32:45 1.12 --- mount_portal.c 1997/11/04 09:11:36 *************** *** 52,57 **** --- 52,58 ---- #include #include #include + #include #include #include #include *************** *** 112,117 **** --- 113,119 ---- struct vfsconf vfc; mode_t um; + int cpid; qelem q; int rc; int so; *************** *** 139,197 **** if (error) usage(); ! /* ! * Get config file and mount point ! */ ! conf = argv[optind]; ! mountpt = argv[optind+1]; - /* - * Construct the listening socket - */ - un.sun_family = AF_UNIX; - if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path)) { - errx(EX_SOFTWARE, "portal socket name too long"); - } - strcpy(un.sun_path, _PATH_TMPPORTAL); - mktemp(un.sun_path); - un.sun_len = strlen(un.sun_path); - - so = socket(AF_UNIX, SOCK_STREAM, 0); - if (so < 0) { - err(EX_OSERR, "socket"); - } - um = umask(077); - (void) unlink(un.sun_path); - if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0) - err(1, NULL); - - (void) unlink(un.sun_path); - (void) umask(um); - - (void) listen(so, 5); - - args.pa_socket = so; - sprintf(tag, "portal:%d", getpid()); - args.pa_config = tag; - - error = getvfsbyname("portal", &vfc); - if (error && vfsisloadable("portal")) { - if (vfsload("portal")) - err(EX_OSERR, "vfsload(portal)"); - endvfsent(); error = getvfsbyname("portal", &vfc); } - if (error) - errx(EX_OSERR, "portal filesystem is not available"); ! rc = mount(vfc.vfc_name, mountpt, mntflags, &args); ! if (rc < 0) ! err(1, NULL); /* ! * Everything is ready to go - now is a good time to fork */ ! daemon(0, 0); /* * Start logging (and change name) --- 141,215 ---- if (error) usage(); ! if ((cpid = fork()) != 0) { ! if (cpid == -1) ! err(1, "fork failed"); ! ! /* ! * Get config file and mount point ! */ ! conf = argv[optind]; ! mountpt = argv[optind+1]; ! ! /* ! * Construct the listening socket ! */ ! un.sun_family = AF_UNIX; ! if (sizeof(_PATH_TMPPORTAL) >= sizeof(un.sun_path)) { ! errx(EX_SOFTWARE, "portal socket name too long"); ! } ! strcpy(un.sun_path, _PATH_TMPPORTAL); ! mktemp(un.sun_path); ! un.sun_len = strlen(un.sun_path); ! ! so = socket(AF_UNIX, SOCK_STREAM, 0); ! if (so < 0) { ! err(EX_OSERR, "socket"); ! } ! um = umask(077); ! (void) unlink(un.sun_path); ! if (bind(so, (struct sockaddr *) &un, sizeof(un)) < 0) ! err(1, NULL); ! ! (void) unlink(un.sun_path); ! (void) umask(um); ! ! (void) listen(so, 5); ! ! args.pa_socket = so; ! sprintf(tag, "portal:%d", cpid); ! args.pa_config = tag; error = getvfsbyname("portal", &vfc); + if (error && vfsisloadable("portal")) { + if (vfsload("portal")) + err(EX_OSERR, "vfsload(portal)"); + endvfsent(); + error = getvfsbyname("portal", &vfc); + } + if (error) + errx(EX_OSERR, "portal filesystem is not available"); + + rc = mount(vfc.vfc_name, mountpt, mntflags, &args); + if (rc < 0) { + kill(cpid, SIGKILL); + err(1, NULL); + } + kill(cpid, SIGCONT); + exit(0); } ! kill(getpid(), SIGSTOP); /* ! * We need to daemonize by hand now :( */ ! setsid(); ! chdir("/"); ! umask(0); ! close(STDIN_FILENO); ! close(STDOUT_FILENO); ! close(STDERR_FILENO); /* * Start logging (and change name)