@@ -1593,7 +1593,7 @@ int faccessat(int dirfd, const char *pathname, int mode, int flags)
15931593 return error;
15941594}
15951595
1596- extern " C"
1596+ extern " C"
15971597int euidaccess (const char *pathname, int mode)
15981598{
15991599 return access (pathname, mode);
@@ -2375,45 +2375,53 @@ extern "C" void unmount_devfs()
23752375
23762376extern " C" int mount_rofs_rootfs (bool pivot_root)
23772377{
2378- int ret;
2379-
2380- if (mkdir (" /rofs" , 0755 ) < 0 )
2381- kprintf (" failed to create /rofs, error = %s\n " , strerror (errno));
2378+ constexpr char * mp = " /rofs" ;
23822379
2383- ret = sys_mount (" /dev/vblk0.1" , " /rofs" , " rofs" , MNT_RDONLY, 0 );
2380+ if (mkdir (mp, 0755 ) < 0 ) {
2381+ int ret = errno;
2382+ kprintf (" failed to create %s, error = %s\n " , mp, strerror (errno));
2383+ return ret;
2384+ }
23842385
2386+ int ret = sys_mount (" /dev/vblk0.1" , mp, " rofs" , MNT_RDONLY, nullptr );
23852387 if (ret) {
2386- kprintf (" failed to mount /rofs , error = %s\n " , strerror (ret));
2387- rmdir (" /rofs " );
2388+ kprintf (" failed to mount %s , error = %s\n " , mp , strerror (ret));
2389+ rmdir (mp );
23882390 return ret;
23892391 }
23902392
23912393 if (pivot_root) {
2392- pivot_rootfs (" /rofs " );
2394+ pivot_rootfs (mp );
23932395 }
23942396
23952397 return 0 ;
23962398}
23972399
2398- extern " C" void mount_zfs_rootfs (bool pivot_root, bool extra_zfs_pools)
2400+ extern " C" int mount_zfs_rootfs (bool pivot_root, bool extra_zfs_pools)
23992401{
2400- if (mkdir (" /zfs" , 0755 ) < 0 )
2401- kprintf (" failed to create /zfs, error = %s\n " , strerror (errno));
2402+ constexpr char * mp = " /zfs" ;
24022403
2403- int ret = sys_mount (" /dev/vblk0.1" , " /zfs" , " zfs" , 0 , (void *)" osv/zfs" );
2404-
2405- if (ret)
2406- kprintf (" failed to mount /zfs, error = %s\n " , strerror (ret));
2407-
2408- if (!pivot_root) {
2409- return ;
2404+ if (mkdir (mp, 0755 ) < 0 ) {
2405+ int ret = errno;
2406+ kprintf (" failed to create %s, error = %s\n " , mp, strerror (errno));
2407+ return ret;
24102408 }
24112409
2412- pivot_rootfs (" /zfs" );
2410+ int ret = sys_mount (" /dev/vblk0.1" , mp, " zfs" , 0 , (void *)" osv/zfs" );
2411+ if (ret) {
2412+ kprintf (" failed to mount %s, error = %s\n " , mp, strerror (ret));
2413+ rmdir (mp);
2414+ return ret;
2415+ }
24132416
2414- if (extra_zfs_pools) {
2415- import_extra_zfs_pools ();
2417+ if (pivot_root) {
2418+ pivot_rootfs (mp);
2419+ if (extra_zfs_pools) {
2420+ import_extra_zfs_pools ();
2421+ }
24162422 }
2423+
2424+ return 0 ;
24172425}
24182426
24192427extern " C" void unmount_rootfs (void )
0 commit comments