void autofs_mounted(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; unsigned long timeout = gopt.am_timeo; close(fh->kernelfd); fh->kernelfd = -1; autofs_get_mp(mp); /* Get autofs protocol version */ if (ioctl(fh->ioctlfd, AUTOFS_IOC_PROTOVER, &fh->version) < 0) { plog(XLOG_ERROR, "AUTOFS_IOC_PROTOVER: %s", strerror(errno)); fh->version = AUTOFS_MIN_VERSION; plog(XLOG_ERROR, "autofs: assuming protocol version %d", fh->version); } else plog(XLOG_INFO, "autofs: using protocol version %d", fh->version); /* set expiration timeout */ if (ioctl(fh->ioctlfd, AUTOFS_IOC_SETTIMEOUT, &timeout) < 0) plog(XLOG_ERROR, "AUTOFS_IOC_SETTIMEOUT: %s", strerror(errno)); /* tell the daemon to call us for expirations */ mp->am_autofs_ttl = clocktime(NULL) + gopt.am_timeo_w; }
static void free_map_if_success(int rc, int term, opaque_t arg) { am_node *mp = (am_node *) arg; mntfs *mf = mp->am_mnt; wchan_t wchan = get_mntfs_wchan(mf); /* * Not unmounting any more */ mf->mf_flags &= ~MFF_UNMOUNTING; /* * If a timeout was deferred because the underlying filesystem * was busy then arrange for a timeout as soon as possible. */ if (mf->mf_flags & MFF_WANTTIMO) { mf->mf_flags &= ~MFF_WANTTIMO; reschedule_timeout_mp(); } if (term) { plog(XLOG_ERROR, "unmount for %s got signal %d", mp->am_path, term); #if defined(DEBUG) && defined(SIGTRAP) /* * dbx likes to put a trap on exit(). * Pretend it succeeded for now... */ if (term == SIGTRAP) { am_unmounted(mp); } #endif /* DEBUG */ #ifdef HAVE_FS_AUTOFS if (mp->am_flags & AMF_AUTOFS) autofs_umount_failed(mp); #endif /* HAVE_FS_AUTOFS */ amd_stats.d_uerr++; } else if (rc) { if (mf->mf_ops == &amfs_program_ops || rc == EBUSY) plog(XLOG_STATS, "\"%s\" on %s still active", mp->am_path, mf->mf_mount); else plog(XLOG_ERROR, "%s: unmount: %s", mp->am_path, strerror(rc)); #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) autofs_get_mp(mp); if (mp->am_flags & AMF_AUTOFS) autofs_umount_failed(mp); #endif /* HAVE_FS_AUTOFS */ amd_stats.d_uerr++; } else { am_unmounted(mp); } /* * Wakeup anything waiting for this unmount */ wakeup(wchan); }