summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2003-02-18 00:45:54 +0000
committerJeremy Katz <katzj@redhat.com>2003-02-18 00:45:54 +0000
commit0c8eba97b35d7503336bc7b2ea154ce98aebaaf2 (patch)
tree7f8da4dbbf3dde47de40ba8eea7a6b583b10e15e
parent9a5589e67a1862f7e49e62d2b65e54db54b7c787 (diff)
downloadanaconda-0c8eba97b35d7503336bc7b2ea154ce98aebaaf2.tar.gz
anaconda-0c8eba97b35d7503336bc7b2ea154ce98aebaaf2.tar.xz
anaconda-0c8eba97b35d7503336bc7b2ea154ce98aebaaf2.zip
support bind mounts for upgrade/rescue mode.
basically, create a new filesystem type and device which get used and add a keyword parameter for mounting the diff looks large, but most of it is adjusting callers of doPwMount in the loader
-rw-r--r--fsset.py39
-rw-r--r--isys/imount.c4
-rw-r--r--isys/imount.h2
-rw-r--r--isys/isys.c7
-rw-r--r--isys/isys.py5
-rw-r--r--loader2/cdinstall.c4
-rw-r--r--loader2/driverdisk.c14
-rw-r--r--loader2/hdinstall.c2
-rw-r--r--loader2/kickstart.c6
-rw-r--r--loader2/loader.c8
-rw-r--r--loader2/method.c8
-rw-r--r--loader2/nfsinstall.c4
-rw-r--r--loader2/usb.c2
13 files changed, 69 insertions, 36 deletions
diff --git a/fsset.py b/fsset.py
index 1bd76fc84..4c23b3b94 100644
--- a/fsset.py
+++ b/fsset.py
@@ -155,12 +155,12 @@ class FileSystemType:
self.extraFormatArgs = []
self.maxLabelChars = 16
- def mount(self, device, mountpoint, readOnly=0):
+ def mount(self, device, mountpoint, readOnly=0, bindMount=0):
if not self.isMountable():
return
iutil.mkdirChain(mountpoint)
isys.mount(device, mountpoint, fstype = self.getName(),
- readOnly = readOnly)
+ readOnly = readOnly, bindMount = bindMount)
def umount(self, device, path):
isys.umount(path, removeDir = 0)
@@ -752,9 +752,18 @@ fileSystemTypeRegister(DevshmFileSystem())
class AutoFileSystem(PsudoFileSystem):
def __init__(self):
PsudoFileSystem.__init__(self, "auto")
-
+
fileSystemTypeRegister(AutoFileSystem())
+class BindFileSystem(AutoFileSystem):
+ def __init__(self):
+ PsudoFileSystem.__init__(self, "bind")
+
+ def isMountable(self):
+ return 1
+
+fileSystemTypeRegister(BindFileSystem())
+
class FileSystemSet:
def __init__(self):
self.messageWindow = None
@@ -1361,14 +1370,19 @@ class FileSystemSetEntry:
def mount(self, chroot='/', devPrefix='/tmp', readOnly = 0):
device = self.device.setupDevice(chroot, devPrefix=devPrefix)
+
# FIXME: we really should migrate before turnOnFilesystems.
# but it's too late now
if (self.migrate == 1) and (self.origfsystem is not None):
self.origfsystem.mount(device, "%s/%s" % (chroot, self.mountpoint),
- readOnly = readOnly)
+ readOnly = readOnly,
+ bindMount = isinstance(self.device,
+ BindMountDevice)
else:
self.fsystem.mount(device, "%s/%s" % (chroot, self.mountpoint),
- readOnly = readOnly)
+ readOnly = readOnly,
+ bindMount = isinstance(self.device,
+ BindMountDevice)
self.mountcount = self.mountcount + 1
@@ -1725,6 +1739,16 @@ class PartedPartitionDevice(PartitionDevice):
# the current minor number allocation
self.device = self.getDevice()
self.partition = None
+
+class BindMountDevice(Device):
+ def __init__(self, directory):
+ Device.__init__(self)
+ self.device = directory
+
+ def setupDevice(self, chroot, devPrefix="/tmp"):
+ return chroot + self.device
+
+
class SwapFileDevice(Device):
def __init__(self, file):
@@ -1854,6 +1878,11 @@ def readFstab (path):
if fields[0] == "none":
device = Device()
+ elif ((string.find(fields[3], "bind") != -1) and
+ fields[0].startswith("/")):
+ # it's a bind mount, they're Weird (tm)
+ device = BindMountDevice(fields[0])
+ fsystem = fileSystemTypeGet("bind")
elif len(fields) >= 6 and fields[0].startswith('LABEL='):
label = fields[0][6:]
if labelToDevice.has_key(label):
diff --git a/isys/imount.c b/isys/imount.c
index a17628fc7..a249888a0 100644
--- a/isys/imount.c
+++ b/isys/imount.c
@@ -14,7 +14,7 @@
static int mkdirIfNone(char * directory);
int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
- char * acct, char * pw) {
+ char * acct, char * pw, int bindmnt) {
char * buf = NULL;
int isnfs = 0;
char * mount_opt = NULL;
@@ -82,6 +82,8 @@ int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
flag = MS_MGC_VAL;
if (rdonly)
flag |= MS_RDONLY;
+ if (bindmnt)
+ flag |= MS_BIND;
if (!strncmp(fs, "vfat", 4))
mount_opt="check=relaxed";
diff --git a/isys/imount.h b/isys/imount.h
index 8fa7e8f26..3f7e826bd 100644
--- a/isys/imount.h
+++ b/isys/imount.h
@@ -7,7 +7,7 @@
#include <sys/mount.h> /* for umount() */
int doPwMount(char * dev, char * where, char * fs, int rdonly, int istty,
- char * acct, char * pw);
+ char * acct, char * pw, int bindmnt);
int mkdirChain(char * origChain);
#endif
diff --git a/isys/isys.c b/isys/isys.c
index d74112607..53098741b 100644
--- a/isys/isys.c
+++ b/isys/isys.c
@@ -487,11 +487,12 @@ static PyObject * doMount(PyObject * s, PyObject * args) {
char * fs, * device, * mntpoint;
int rc;
int readOnly;
+ int bindMount;
- if (!PyArg_ParseTuple(args, "sssi", &fs, &device, &mntpoint,
- &readOnly)) return NULL;
+ if (!PyArg_ParseTuple(args, "sssii", &fs, &device, &mntpoint,
+ &readOnly, &bindMount)) return NULL;
- rc = doPwMount(device, mntpoint, fs, readOnly, 0, NULL, NULL);
+ rc = doPwMount(device, mntpoint, fs, readOnly, 0, NULL, NULL, bindMount);
if (rc == IMOUNT_ERR_ERRNO)
PyErr_SetFromErrno(PyExc_SystemError);
else if (rc)
diff --git a/isys/isys.py b/isys/isys.py
index 2f104ee5c..176b572ab 100644
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -141,7 +141,7 @@ def ddfile(file, megs, pw = None):
os.close(fd)
-def mount(device, location, fstype = "ext2", readOnly = 0):
+def mount(device, location, fstype = "ext2", readOnly = 0, bindMount = 0):
location = os.path.normpath(location)
#
@@ -160,7 +160,8 @@ def mount(device, location, fstype = "ext2", readOnly = 0):
mountCount[location] = mountCount[location] + 1
return
- rc = _isys.mount(fstype, device, location, readOnly)
+ log("going to mount %s on %s" %(device, location))
+ rc = _isys.mount(fstype, device, location, readOnly, bindMount)
if not rc:
mountCount[location] = 1
diff --git a/loader2/cdinstall.c b/loader2/cdinstall.c
index 2e44b6cbc..f9366f660 100644
--- a/loader2/cdinstall.c
+++ b/loader2/cdinstall.c
@@ -158,7 +158,7 @@ static void mountCdromStage2(char *cddev) {
do {
do {
if (doPwMount("/tmp/cdrom", "/mnt/source",
- "iso9660", 1, 0, NULL, NULL)) {
+ "iso9660", 1, 0, NULL, NULL, 0)) {
ejectCdrom();
wrongCDMessage();
} else {
@@ -317,7 +317,7 @@ char * setupCdrom(char * location,
logMessage("trying to mount device %s", kd->known[i].name);
devMakeInode(kd->known[i].name, "/tmp/cdrom");
if (!doPwMount("/tmp/cdrom", "/mnt/source", "iso9660", 1, 0,
- NULL, NULL)) {
+ NULL, NULL, 0)) {
if (!access("/mnt/source/RedHat/base/stage2.img", R_OK) &&
(FL_RESCUE(flags) || !access("/mnt/source/.discinfo", R_OK))) {
rc = mountStage2("/mnt/source/RedHat/base/stage2.img");
diff --git a/loader2/driverdisk.c b/loader2/driverdisk.c
index 18386aa1f..3a0ca7b02 100644
--- a/loader2/driverdisk.c
+++ b/loader2/driverdisk.c
@@ -224,9 +224,9 @@ int loadDriverFromMedia(int class, moduleList modLoaded,
devMakeInode(device, "/tmp/dddev");
logMessage("trying to mount %s", device);
- if (doPwMount("/tmp/dddev", "/tmp/drivers", "vfat", 1, 0, NULL, NULL)) {
- if (doPwMount("/tmp/dddev", "/tmp/drivers", "ext2", 1, 0, NULL, NULL)) {
- if (doPwMount("/tmp/dddev", "/tmp/drivers", "iso9660", 1, 0, NULL, NULL)) {
+ if (doPwMount("/tmp/dddev", "/tmp/drivers", "vfat", 1, 0, NULL, NULL, 0)) {
+ if (doPwMount("/tmp/dddev", "/tmp/drivers", "ext2", 1, 0, NULL, NULL, 0)) {
+ if (doPwMount("/tmp/dddev", "/tmp/drivers", "iso9660", 1, 0, NULL, NULL, 0)) {
newtWinMessage(_("Error"), _("OK"),
_("Failed to mount driver disk."));
stage = DEV_INSERT;
@@ -394,15 +394,15 @@ void useKickstartDD(struct loaderData_s * loaderData, int argc,
devMakeInode(dev, "/tmp/dddev");
if (fstype) {
if (!doPwMount("/tmp/dddev", "/tmp/drivers", fstype, 1, 0,
- NULL, NULL)) {
+ NULL, NULL, 0)) {
logMessage("unable to mount %s as %s", dev, fstype);
return;
}
}
- if (doPwMount("/tmp/dddev", "/tmp/drivers", "vfat", 1, 0, NULL, NULL)) {
- if (doPwMount("/tmp/dddev", "/tmp/drivers", "ext2", 1, 0, NULL, NULL)) {
- if (doPwMount("/tmp/dddev", "/tmp/drivers", "iso9660", 1, 0, NULL, NULL)) {
+ if (doPwMount("/tmp/dddev", "/tmp/drivers", "vfat", 1, 0, NULL, NULL, 0)) {
+ if (doPwMount("/tmp/dddev", "/tmp/drivers", "ext2", 1, 0, NULL, NULL, 0)) {
+ if (doPwMount("/tmp/dddev", "/tmp/drivers", "iso9660", 1, 0, NULL, NULL, 0)) {
logMessage("unable to mount driver disk %s", dev);
return;
}
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c
index f68414dd6..ffde08708 100644
--- a/loader2/hdinstall.c
+++ b/loader2/hdinstall.c
@@ -229,7 +229,7 @@ static char * setupIsoImages(char * device, char * dirName, int flags) {
/* XXX try to mount as ext2 and then vfat */
for (type=typetry; *type; type++) {
- if (!doPwMount("/tmp/hddev", "/tmp/hdimage", *type, 1, 0, NULL, NULL))
+ if (!doPwMount("/tmp/hddev", "/tmp/hdimage", *type, 1, 0, NULL, NULL, 0))
break;
}
diff --git a/loader2/kickstart.c b/loader2/kickstart.c
index 73ce0c8f2..2cad63fcc 100644
--- a/loader2/kickstart.c
+++ b/loader2/kickstart.c
@@ -276,9 +276,9 @@ int getKickstartFromBlockDevice(char *device, char *path) {
if (devMakeInode(device, "/tmp/kssrcdev"))
return 1;
- if ((doPwMount("/tmp/kssrcdev", "/tmp/ks", "vfat", 1, 0, NULL, NULL)) &&
- doPwMount("/tmp/kssrcdev", "/tmp/ks", "ext2", 1, 0, NULL, NULL) &&
- doPwMount("/tmp/kssrcdev", "/tmp/ks", "iso9660", 1, 0, NULL, NULL)) {
+ if ((doPwMount("/tmp/kssrcdev", "/tmp/ks", "vfat", 1, 0, NULL, NULL, 0)) &&
+ doPwMount("/tmp/kssrcdev", "/tmp/ks", "ext2", 1, 0, NULL, NULL, 0) &&
+ doPwMount("/tmp/kssrcdev", "/tmp/ks", "iso9660", 1, 0, NULL, NULL, 0)) {
logMessage("failed to mount /dev/%s: %s", device, strerror(errno));
return 2;
}
diff --git a/loader2/loader.c b/loader2/loader.c
index 76aff1dcb..c9c0069c0 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -143,7 +143,7 @@ int setupRamdisk(void) {
gunzip_close(f);
}
- if (doPwMount(RAMDISK_DEVICE, "/tmp/ramfs", "ext2", 0, 0, NULL, NULL))
+ if (doPwMount(RAMDISK_DEVICE, "/tmp/ramfs", "ext2", 0, 0, NULL, NULL, 0))
logMessage("failed to mount ramfs image");
return 0;
@@ -152,7 +152,7 @@ int setupRamdisk(void) {
void setupRamfs(void) {
mkdirChain("/tmp/ramfs");
- doPwMount("none", "/tmp/ramfs", "ramfs", 0, 0, NULL, NULL);
+ doPwMount("none", "/tmp/ramfs", "ramfs", 0, 0, NULL, NULL, 0);
}
@@ -314,9 +314,9 @@ void loadUpdates(struct knownDevices *kd, int flags) {
devMakeInode(device, "/tmp/upd.disk");
if (doPwMount("/tmp/upd.disk", "/tmp/update-disk", "ext2", 1, 0,
- NULL, NULL) &&
+ NULL, NULL, 0) &&
doPwMount("/tmp/upd.disk", "/tmp/update-disk", "iso9660", 1, 0,
- NULL, NULL)) {
+ NULL, NULL, 0)) {
newtWinMessage(_("Error"), _("OK"),
_("Failed to mount updates disk"));
} else {
diff --git a/loader2/method.c b/loader2/method.c
index 6cef9be5f..b2a4ecc5f 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -134,11 +134,11 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) {
close(loopfd);
if (doPwMount(filename, mntpoint, "iso9660", 1,
- 0, NULL, NULL)) {
+ 0, NULL, NULL, 0)) {
if (doPwMount(filename, mntpoint, "ext2", 1,
- 0, NULL, NULL)) {
+ 0, NULL, NULL, 0)) {
if (doPwMount(filename, mntpoint, "cramfs", 1,
- 0, NULL, NULL)) {
+ 0, NULL, NULL, 0)) {
logMessage("failed to mount loop: %s",
strerror(errno));
@@ -213,7 +213,7 @@ int readStampFileFromIso(char *file, char **timestamp, char **releasedescr) {
if (S_ISBLK(sb.st_mode)) {
filetype = 1;
if (doPwMount(file, "/tmp/testmnt",
- "iso9660", 1, 0, NULL, NULL)) {
+ "iso9660", 1, 0, NULL, NULL, 0)) {
logMessage("Failed to mount device %s to get description", file);
return -1;
}
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index 17605469a..e08339551 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -169,7 +169,7 @@ char * mountNfsImage(struct installMethod * method,
stage = NFS_STAGE_NFS;
- if (!doPwMount(fullPath, "/mnt/source", "nfs", 1, 0, NULL, NULL)) {
+ if (!doPwMount(fullPath, "/mnt/source", "nfs", 1, 0, NULL, NULL, 0)) {
logMessage("mounted %s on /mnt/source", fullPath);
if (!access("/mnt/source/RedHat/base/stage2.img", R_OK)) {
logMessage("can access stage2.img");
@@ -329,7 +329,7 @@ int kickstartFromNfs(char * url, struct knownDevices * kd,
logMessage("ks location: nfs://%s/%s", host, file);
- if (!doPwMount(host, "/tmp/ks", "nfs", 1, 0, NULL, NULL)) {
+ if (!doPwMount(host, "/tmp/ks", "nfs", 1, 0, NULL, NULL, 0)) {
char * buf;
buf = alloca(strlen(file) + 10);
diff --git a/loader2/usb.c b/loader2/usb.c
index ac847cfc1..028559ebe 100644
--- a/loader2/usb.c
+++ b/loader2/usb.c
@@ -96,7 +96,7 @@ int usbInitialize(moduleList modLoaded, moduleDeps modDeps,
if (FL_TESTING(flags)) return 0;
if (doPwMount("/proc/bus/usb", "/proc/bus/usb", "usbdevfs", 0, 0,
- NULL, NULL))
+ NULL, NULL, 0))
logMessage("failed to mount device usbdevfs: %s", strerror(errno));
/* sleep so we make sure usb devices get properly enumerated.