+
+#ifdef FILESYS
+/* Figure out what block devices to cast in the various Pintos roles. */
+static void
+locate_block_devices (void)
+{
+ locate_block_device (BLOCK_FILESYS, filesys_bdev_name);
+ locate_block_device (BLOCK_SCRATCH, scratch_bdev_name);
+#ifdef VM
+ locate_block_device (BLOCK_SWAP, swap_bdev_name);
+#endif
+}
+
+/* Figures out what block device to use for the given ROLE: the
+ block device with the given NAME, if NAME is non-null,
+ otherwise the first block device in probe order of type
+ ROLE. */
+static void
+locate_block_device (enum block_type role, const char *name)
+{
+ struct block *block = NULL;
+
+ if (name != NULL)
+ {
+ block = block_get_by_name (name);
+ if (block == NULL)
+ PANIC ("No such block device \"%s\"", name);
+ }
+ else
+ {
+ for (block = block_first (); block != NULL; block = block_next (block))
+ if (block_type (block) == role)
+ break;
+ }
+
+ if (block != NULL)
+ {
+ printf ("%s: using %s\n", block_type_name (role), block_name (block));
+ block_set_role (role, block);
+ }
+}
+#endif