summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall/ufs.c
diff options
context:
space:
mode:
authorcperciva <cperciva@FreeBSD.org>2009-06-24 04:56:13 +0000
committercperciva <cperciva@FreeBSD.org>2009-06-24 04:56:13 +0000
commitdaf18f9631bdf96db3941fb37ecee3310bd64220 (patch)
tree8815fbd9bbacf66f5a0638cef5e30b6ecb6128c4 /usr.sbin/sysinstall/ufs.c
parent323707be16260ec873618e15958a9c1c33cf0e85 (diff)
downloadFreeBSD-src-daf18f9631bdf96db3941fb37ecee3310bd64220.zip
FreeBSD-src-daf18f9631bdf96db3941fb37ecee3310bd64220.tar.gz
Add detection of UFS filesystems.
PR: bin/135565 Submitted by: Daniel O'Connor Reviewed by: randi MFC after: 1 month
Diffstat (limited to 'usr.sbin/sysinstall/ufs.c')
-rw-r--r--usr.sbin/sysinstall/ufs.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/usr.sbin/sysinstall/ufs.c b/usr.sbin/sysinstall/ufs.c
index c9515ae..d8a6fcf 100644
--- a/usr.sbin/sysinstall/ufs.c
+++ b/usr.sbin/sysinstall/ufs.c
@@ -39,11 +39,47 @@
#include "sysinstall.h"
#include <sys/fcntl.h>
#include <sys/param.h>
+#include <sys/mount.h>
+#include <ufs/ufs/ufsmount.h>
-/* No init or shutdown routines necessary - all done in mediaSetUFS() */
+static Boolean UFSMounted;
+static char mountpoint[] = "/dist";
+
+Boolean
+mediaInitUFS(Device *dev)
+{
+ struct ufs_args args;
+
+ if (UFSMounted)
+ return TRUE;
+
+ Mkdir(mountpoint);
+ memset(&args, 0, sizeof(args));
+ args.fspec = dev->devname;
+
+ if (mount("ufs", mountpoint, MNT_RDONLY, (caddr_t)&args) == -1) {
+ msgConfirm("Error mounting %s on %s: %s (%u)", args.fspec, mountpoint, strerror(errno), errno);
+ return FALSE;
+ }
+ UFSMounted = TRUE;
+ return TRUE;
+}
FILE *
mediaGetUFS(Device *dev, char *file, Boolean probe)
{
return mediaGenericGet((char *)dev->private, file);
}
+
+void
+mediaShutdownUFS(Device *dev)
+{
+ if (!UFSMounted)
+ return;
+ if (unmount(mountpoint, MNT_FORCE) != 0)
+ msgConfirm("Could not unmount the UFS partition from %s: %s",
+ mountpoint, strerror(errno));
+ else
+ UFSMounted = FALSE;
+ return;
+}
OpenPOWER on IntegriCloud