diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /init/do_mounts.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'init/do_mounts.c')
-rw-r--r-- | init/do_mounts.c | 91 |
1 files changed, 81 insertions, 10 deletions
diff --git a/init/do_mounts.c b/init/do_mounts.c index 02e3ca4fc527..c0851a8e030c 100644 --- a/init/do_mounts.c +++ b/init/do_mounts.c | |||
@@ -58,6 +58,62 @@ static int __init readwrite(char *str) | |||
58 | __setup("ro", readonly); | 58 | __setup("ro", readonly); |
59 | __setup("rw", readwrite); | 59 | __setup("rw", readwrite); |
60 | 60 | ||
61 | #ifdef CONFIG_BLOCK | ||
62 | /** | ||
63 | * match_dev_by_uuid - callback for finding a partition using its uuid | ||
64 | * @dev: device passed in by the caller | ||
65 | * @data: opaque pointer to a 36 byte char array with a UUID | ||
66 | * | ||
67 | * Returns 1 if the device matches, and 0 otherwise. | ||
68 | */ | ||
69 | static int match_dev_by_uuid(struct device *dev, void *data) | ||
70 | { | ||
71 | u8 *uuid = data; | ||
72 | struct hd_struct *part = dev_to_part(dev); | ||
73 | |||
74 | if (!part->info) | ||
75 | goto no_match; | ||
76 | |||
77 | if (memcmp(uuid, part->info->uuid, sizeof(part->info->uuid))) | ||
78 | goto no_match; | ||
79 | |||
80 | return 1; | ||
81 | no_match: | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | |||
86 | /** | ||
87 | * devt_from_partuuid - looks up the dev_t of a partition by its UUID | ||
88 | * @uuid: 36 byte char array containing a hex ascii UUID | ||
89 | * | ||
90 | * The function will return the first partition which contains a matching | ||
91 | * UUID value in its partition_meta_info struct. This does not search | ||
92 | * by filesystem UUIDs. | ||
93 | * | ||
94 | * Returns the matching dev_t on success or 0 on failure. | ||
95 | */ | ||
96 | static dev_t devt_from_partuuid(char *uuid_str) | ||
97 | { | ||
98 | dev_t res = 0; | ||
99 | struct device *dev = NULL; | ||
100 | u8 uuid[16]; | ||
101 | |||
102 | /* Pack the requested UUID in the expected format. */ | ||
103 | part_pack_uuid(uuid_str, uuid); | ||
104 | |||
105 | dev = class_find_device(&block_class, NULL, uuid, &match_dev_by_uuid); | ||
106 | if (!dev) | ||
107 | goto done; | ||
108 | |||
109 | res = dev->devt; | ||
110 | put_device(dev); | ||
111 | |||
112 | done: | ||
113 | return res; | ||
114 | } | ||
115 | #endif | ||
116 | |||
61 | /* | 117 | /* |
62 | * Convert a name into device number. We accept the following variants: | 118 | * Convert a name into device number. We accept the following variants: |
63 | * | 119 | * |
@@ -68,6 +124,8 @@ __setup("rw", readwrite); | |||
68 | * of partition - device number of disk plus the partition number | 124 | * of partition - device number of disk plus the partition number |
69 | * 5) /dev/<disk_name>p<decimal> - same as the above, that form is | 125 | * 5) /dev/<disk_name>p<decimal> - same as the above, that form is |
70 | * used when disk name of partitioned disk ends on a digit. | 126 | * used when disk name of partitioned disk ends on a digit. |
127 | * 6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the | ||
128 | * unique id of a partition if the partition table provides it. | ||
71 | * | 129 | * |
72 | * If name doesn't have fall into the categories above, we return (0,0). | 130 | * If name doesn't have fall into the categories above, we return (0,0). |
73 | * block_class is used to check if something is a disk name. If the disk | 131 | * block_class is used to check if something is a disk name. If the disk |
@@ -82,6 +140,18 @@ dev_t name_to_dev_t(char *name) | |||
82 | dev_t res = 0; | 140 | dev_t res = 0; |
83 | int part; | 141 | int part; |
84 | 142 | ||
143 | #ifdef CONFIG_BLOCK | ||
144 | if (strncmp(name, "PARTUUID=", 9) == 0) { | ||
145 | name += 9; | ||
146 | if (strlen(name) != 36) | ||
147 | goto fail; | ||
148 | res = devt_from_partuuid(name); | ||
149 | if (!res) | ||
150 | goto fail; | ||
151 | goto done; | ||
152 | } | ||
153 | #endif | ||
154 | |||
85 | if (strncmp(name, "/dev/", 5) != 0) { | 155 | if (strncmp(name, "/dev/", 5) != 0) { |
86 | unsigned maj, min; | 156 | unsigned maj, min; |
87 | 157 | ||
@@ -116,7 +186,7 @@ dev_t name_to_dev_t(char *name) | |||
116 | goto done; | 186 | goto done; |
117 | 187 | ||
118 | /* | 188 | /* |
119 | * try non-existant, but valid partition, which may only exist | 189 | * try non-existent, but valid partition, which may only exist |
120 | * after revalidating the disk, like partitioned md devices | 190 | * after revalidating the disk, like partitioned md devices |
121 | */ | 191 | */ |
122 | while (p > s && isdigit(p[-1])) | 192 | while (p > s && isdigit(p[-1])) |
@@ -221,9 +291,10 @@ static int __init do_mount_root(char *name, char *fs, int flags, void *data) | |||
221 | if (err) | 291 | if (err) |
222 | return err; | 292 | return err; |
223 | 293 | ||
224 | sys_chdir("/root"); | 294 | sys_chdir((const char __user __force *)"/root"); |
225 | ROOT_DEV = current->fs->pwd.mnt->mnt_sb->s_dev; | 295 | ROOT_DEV = current->fs->pwd.mnt->mnt_sb->s_dev; |
226 | printk("VFS: Mounted root (%s filesystem)%s on device %u:%u.\n", | 296 | printk(KERN_INFO |
297 | "VFS: Mounted root (%s filesystem)%s on device %u:%u.\n", | ||
227 | current->fs->pwd.mnt->mnt_sb->s_type->name, | 298 | current->fs->pwd.mnt->mnt_sb->s_type->name, |
228 | current->fs->pwd.mnt->mnt_sb->s_flags & MS_RDONLY ? | 299 | current->fs->pwd.mnt->mnt_sb->s_flags & MS_RDONLY ? |
229 | " readonly" : "", MAJOR(ROOT_DEV), MINOR(ROOT_DEV)); | 300 | " readonly" : "", MAJOR(ROOT_DEV), MINOR(ROOT_DEV)); |
@@ -291,13 +362,13 @@ out: | |||
291 | #ifdef CONFIG_ROOT_NFS | 362 | #ifdef CONFIG_ROOT_NFS |
292 | static int __init mount_nfs_root(void) | 363 | static int __init mount_nfs_root(void) |
293 | { | 364 | { |
294 | void *data = nfs_root_data(); | 365 | char *root_dev, *root_data; |
295 | 366 | ||
296 | create_dev("/dev/root", ROOT_DEV); | 367 | if (nfs_root_data(&root_dev, &root_data) != 0) |
297 | if (data && | 368 | return 0; |
298 | do_mount_root("/dev/root", "nfs", root_mountflags, data) == 0) | 369 | if (do_mount_root(root_dev, "nfs", root_mountflags, root_data) != 0) |
299 | return 1; | 370 | return 0; |
300 | return 0; | 371 | return 1; |
301 | } | 372 | } |
302 | #endif | 373 | #endif |
303 | 374 | ||
@@ -418,5 +489,5 @@ void __init prepare_namespace(void) | |||
418 | out: | 489 | out: |
419 | devtmpfs_mount("dev"); | 490 | devtmpfs_mount("dev"); |
420 | sys_mount(".", "/", NULL, MS_MOVE, NULL); | 491 | sys_mount(".", "/", NULL, MS_MOVE, NULL); |
421 | sys_chroot("."); | 492 | sys_chroot((const char __user __force *)"."); |
422 | } | 493 | } |