@@ -338,31 +338,22 @@ __setup("rootflags=", root_data_setup);
338
338
__setup ("rootfstype=" , fs_names_setup );
339
339
__setup ("rootdelay=" , root_delay_setup );
340
340
341
- static void __init get_fs_names (char * page )
341
+ static int __init split_fs_names (char * page , char * names )
342
342
{
343
- char * s = page ;
343
+ int count = 0 ;
344
+ char * p = page ;
344
345
345
- if (root_fs_names ) {
346
- strcpy (page , root_fs_names );
347
- while (* s ++ ) {
348
- if (s [-1 ] == ',' )
349
- s [-1 ] = '\0' ;
350
- }
351
- } else {
352
- int len = get_filesystem_list (page );
353
- char * p , * next ;
354
-
355
- page [len ] = '\0' ;
356
- for (p = page - 1 ; p ; p = next ) {
357
- next = strchr (++ p , '\n' );
358
- if (* p ++ != '\t' )
359
- continue ;
360
- while ((* s ++ = * p ++ ) != '\n' )
361
- ;
362
- s [-1 ] = '\0' ;
363
- }
346
+ strcpy (p , root_fs_names );
347
+ while (* p ++ ) {
348
+ if (p [-1 ] == ',' )
349
+ p [-1 ] = '\0' ;
364
350
}
365
- * s = '\0' ;
351
+ * p = '\0' ;
352
+
353
+ for (p = page ; * p ; p += strlen (p )+ 1 )
354
+ count ++ ;
355
+
356
+ return count ;
366
357
}
367
358
368
359
static int __init do_mount_root (const char * name , const char * fs ,
@@ -408,12 +399,16 @@ void __init mount_block_root(char *name, int flags)
408
399
char * fs_names = page_address (page );
409
400
char * p ;
410
401
char b [BDEVNAME_SIZE ];
402
+ int num_fs , i ;
411
403
412
404
scnprintf (b , BDEVNAME_SIZE , "unknown-block(%u,%u)" ,
413
405
MAJOR (ROOT_DEV ), MINOR (ROOT_DEV ));
414
- get_fs_names (fs_names );
406
+ if (root_fs_names )
407
+ num_fs = split_fs_names (fs_names , root_fs_names );
408
+ else
409
+ num_fs = list_bdev_fs_names (fs_names , PAGE_SIZE );
415
410
retry :
416
- for (p = fs_names ; * p ; p += strlen (p )+ 1 ) {
411
+ for (i = 0 , p = fs_names ; i < num_fs ; i ++ , p += strlen (p )+ 1 ) {
417
412
int err = do_mount_root (name , p , flags , root_mount_data );
418
413
switch (err ) {
419
414
case 0 :
@@ -442,7 +437,7 @@ void __init mount_block_root(char *name, int flags)
442
437
printk ("List of all partitions:\n" );
443
438
printk_all_partitions ();
444
439
printk ("No filesystem could mount root, tried: " );
445
- for (p = fs_names ; * p ; p += strlen (p )+ 1 )
440
+ for (i = 0 , p = fs_names ; i < num_fs ; i ++ , p += strlen (p )+ 1 )
446
441
printk (" %s" , p );
447
442
printk ("\n" );
448
443
panic ("VFS: Unable to mount root fs on %s" , b );
@@ -526,6 +521,47 @@ static int __init mount_cifs_root(void)
526
521
}
527
522
#endif
528
523
524
+ static bool __init fs_is_nodev (char * fstype )
525
+ {
526
+ struct file_system_type * fs = get_fs_type (fstype );
527
+ bool ret = false;
528
+
529
+ if (fs ) {
530
+ ret = !(fs -> fs_flags & FS_REQUIRES_DEV );
531
+ put_filesystem (fs );
532
+ }
533
+
534
+ return ret ;
535
+ }
536
+
537
+ static int __init mount_nodev_root (void )
538
+ {
539
+ char * fs_names , * fstype ;
540
+ int err = - EINVAL ;
541
+ int num_fs , i ;
542
+
543
+ fs_names = (void * )__get_free_page (GFP_KERNEL );
544
+ if (!fs_names )
545
+ return - EINVAL ;
546
+ num_fs = split_fs_names (fs_names , root_fs_names );
547
+
548
+ for (i = 0 , fstype = fs_names ; i < num_fs ;
549
+ i ++ , fstype += strlen (fstype ) + 1 ) {
550
+ if (!fs_is_nodev (fstype ))
551
+ continue ;
552
+ err = do_mount_root (root_device_name , fstype , root_mountflags ,
553
+ root_mount_data );
554
+ if (!err )
555
+ break ;
556
+ if (err != - EACCES && err != - EINVAL )
557
+ panic ("VFS: Unable to mount root \"%s\" (%s), err=%d\n" ,
558
+ root_device_name , fstype , err );
559
+ }
560
+
561
+ free_page ((unsigned long )fs_names );
562
+ return err ;
563
+ }
564
+
529
565
void __init mount_root (void )
530
566
{
531
567
#ifdef CONFIG_ROOT_NFS
@@ -542,6 +578,10 @@ void __init mount_root(void)
542
578
return ;
543
579
}
544
580
#endif
581
+ if (ROOT_DEV == 0 && root_device_name && root_fs_names ) {
582
+ if (mount_nodev_root () == 0 )
583
+ return ;
584
+ }
545
585
#ifdef CONFIG_BLOCK
546
586
{
547
587
int err = create_dev ("/dev/root" , ROOT_DEV );
0 commit comments