vfs_mount.c (130585) | vfs_mount.c (130640) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 45 unchanged lines hidden (view full) --- 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 */ 60 61#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 45 unchanged lines hidden (view full) --- 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * SUCH DAMAGE. 59 */ 60 61#include <sys/cdefs.h> |
62__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 130585 2004-06-16 09:47:26Z phk $"); | 62__FBSDID("$FreeBSD: head/sys/kern/vfs_mount.c 130640 2004-06-17 17:16:53Z phk $"); |
63 64#include <sys/param.h> 65#include <sys/conf.h> 66#include <sys/cons.h> 67#include <sys/jail.h> 68#include <sys/kernel.h> 69#include <sys/linker.h> 70#include <sys/mac.h> --- 71 unchanged lines hidden (view full) --- 142 "cd9660:cd0", 143 "cd9660:acd0", 144 NULL 145}; 146 147/* legacy find-root code */ 148char *rootdevnames[2] = {NULL, NULL}; 149static int setrootbyname(char *name); | 63 64#include <sys/param.h> 65#include <sys/conf.h> 66#include <sys/cons.h> 67#include <sys/jail.h> 68#include <sys/kernel.h> 69#include <sys/linker.h> 70#include <sys/mac.h> --- 71 unchanged lines hidden (view full) --- 142 "cd9660:cd0", 143 "cd9660:acd0", 144 NULL 145}; 146 147/* legacy find-root code */ 148char *rootdevnames[2] = {NULL, NULL}; 149static int setrootbyname(char *name); |
150struct cdev *rootdev = NODEV; | 150struct cdev *rootdev = NULL; |
151 152/* 153 * Has to be dynamic as the value of rootdev can change; however, it can't 154 * change after the root is mounted, so a user process can't access this 155 * sysctl until after the value is unchangeable. 156 */ 157static int 158sysctl_rootdev(SYSCTL_HANDLER_ARGS) 159{ 160 int error; 161 162 /* _RD prevents this from happening. */ 163 KASSERT(req->newptr == NULL, ("Attempt to change root device name")); 164 | 151 152/* 153 * Has to be dynamic as the value of rootdev can change; however, it can't 154 * change after the root is mounted, so a user process can't access this 155 * sysctl until after the value is unchangeable. 156 */ 157static int 158sysctl_rootdev(SYSCTL_HANDLER_ARGS) 159{ 160 int error; 161 162 /* _RD prevents this from happening. */ 163 KASSERT(req->newptr == NULL, ("Attempt to change root device name")); 164 |
165 if (rootdev != NODEV) | 165 if (rootdev != NULL) |
166 error = sysctl_handle_string(oidp, rootdev->si_name, 0, req); 167 else 168 error = sysctl_handle_string(oidp, "", 0, req); 169 170 return (error); 171} 172 173SYSCTL_PROC(_kern, OID_AUTO, rootdev, CTLTYPE_STRING | CTLFLAG_RD, --- 1160 unchanged lines hidden (view full) --- 1334 goto done; 1335 } 1336 1337 /* do our best to set rootdev */ 1338 if (path[0] != '\0' && setrootbyname(path)) 1339 printf("setrootbyname failed\n"); 1340 1341 /* If the root device is a type "memory disk", mount RW */ | 166 error = sysctl_handle_string(oidp, rootdev->si_name, 0, req); 167 else 168 error = sysctl_handle_string(oidp, "", 0, req); 169 170 return (error); 171} 172 173SYSCTL_PROC(_kern, OID_AUTO, rootdev, CTLTYPE_STRING | CTLFLAG_RD, --- 1160 unchanged lines hidden (view full) --- 1334 goto done; 1335 } 1336 1337 /* do our best to set rootdev */ 1338 if (path[0] != '\0' && setrootbyname(path)) 1339 printf("setrootbyname failed\n"); 1340 1341 /* If the root device is a type "memory disk", mount RW */ |
1342 if (rootdev != NODEV && devsw(rootdev) != NULL) { | 1342 if (rootdev != NULL && devsw(rootdev) != NULL) { |
1343 devname = devtoname(rootdev); 1344 if (devname[0] == 'm' && devname[1] == 'd') 1345 mp->mnt_flag &= ~MNT_RDONLY; 1346 } 1347 1348 error = VFS_MOUNT(mp, NULL, NULL, NULL, curthread); 1349 1350done: --- 101 unchanged lines hidden (view full) --- 1452getdiskbyname(char *name) { 1453 char *cp; 1454 struct cdev *dev; 1455 1456 cp = name; 1457 if (!bcmp(cp, "/dev/", 5)) 1458 cp += 5; 1459 | 1343 devname = devtoname(rootdev); 1344 if (devname[0] == 'm' && devname[1] == 'd') 1345 mp->mnt_flag &= ~MNT_RDONLY; 1346 } 1347 1348 error = VFS_MOUNT(mp, NULL, NULL, NULL, curthread); 1349 1350done: --- 101 unchanged lines hidden (view full) --- 1452getdiskbyname(char *name) { 1453 char *cp; 1454 struct cdev *dev; 1455 1456 cp = name; 1457 if (!bcmp(cp, "/dev/", 5)) 1458 cp += 5; 1459 |
1460 dev = NODEV; | 1460 dev = NULL; |
1461 EVENTHANDLER_INVOKE(dev_clone, cp, strlen(cp), &dev); 1462 return (dev); 1463} 1464 1465/* 1466 * Set rootdev to match (name), given that we expect it to 1467 * refer to a disk-like device. 1468 */ 1469static int 1470setrootbyname(char *name) 1471{ 1472 struct cdev *diskdev; 1473 1474 diskdev = getdiskbyname(name); | 1461 EVENTHANDLER_INVOKE(dev_clone, cp, strlen(cp), &dev); 1462 return (dev); 1463} 1464 1465/* 1466 * Set rootdev to match (name), given that we expect it to 1467 * refer to a disk-like device. 1468 */ 1469static int 1470setrootbyname(char *name) 1471{ 1472 struct cdev *diskdev; 1473 1474 diskdev = getdiskbyname(name); |
1475 if (diskdev != NODEV) { | 1475 if (diskdev != NULL) { |
1476 rootdev = diskdev; 1477 return (0); 1478 } 1479 1480 return (1); 1481} 1482 1483/* Show the struct cdev *for a disk specified by name */ 1484#ifdef DDB 1485DB_SHOW_COMMAND(disk, db_getdiskbyname) 1486{ 1487 struct cdev *dev; 1488 1489 if (modif[0] == '\0') { 1490 db_error("usage: show disk/devicename"); 1491 return; 1492 } 1493 dev = getdiskbyname(modif); | 1476 rootdev = diskdev; 1477 return (0); 1478 } 1479 1480 return (1); 1481} 1482 1483/* Show the struct cdev *for a disk specified by name */ 1484#ifdef DDB 1485DB_SHOW_COMMAND(disk, db_getdiskbyname) 1486{ 1487 struct cdev *dev; 1488 1489 if (modif[0] == '\0') { 1490 db_error("usage: show disk/devicename"); 1491 return; 1492 } 1493 dev = getdiskbyname(modif); |
1494 if (dev != NODEV) | 1494 if (dev != NULL) |
1495 db_printf("struct cdev *= %p\n", dev); 1496 else 1497 db_printf("No disk device matched.\n"); 1498} 1499#endif 1500 1501/* 1502 * Get a mount option by its name. --- 58 unchanged lines hidden --- | 1495 db_printf("struct cdev *= %p\n", dev); 1496 else 1497 db_printf("No disk device matched.\n"); 1498} 1499#endif 1500 1501/* 1502 * Get a mount option by its name. --- 58 unchanged lines hidden --- |