@@ -1331,16 +1331,14 @@ func verifyDevNull(f *os.File) error {
13311331
13321332// maskDir mounts a read-only tmpfs on top of the specified path.
13331333func maskDir (path , mountLabel string ) error {
1334- // On most kernels `nr_inodes=1` works fine. However, Ubuntu 20.04 (Focal) with
1335- // the official 5.4 kernel carries a private patch in mm/shmem.c that rejects
1336- // "nr_inodes<2", so let's keep `nr_inodes=2` here!
1337- // For reference, search for "case Opt_nr_inodes" in:
1338- // https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal/plain/mm/shmem.c?h=Ubuntu-5.4.0-216.236
1339- err := mount ("tmpfs" , path , "tmpfs" , unix .MS_RDONLY , label .FormatMountLabel ("nr_blocks=1,nr_inodes=2" , mountLabel ))
1340- // We don't know whether some kernels will fail with "nr_inodes=2",
1341- // so let's fall back to mount a tmpfs without this option.
1342- if errors .Is (err , unix .EINVAL ) {
1343- err = mount ("tmpfs" , path , "tmpfs" , unix .MS_RDONLY , label .FormatMountLabel ("nr_blocks=1" , mountLabel ))
1334+ err := mount ("tmpfs" , path , "tmpfs" , unix .MS_RDONLY , label .FormatMountLabel ("nr_blocks=1,nr_inodes=1" , mountLabel ))
1335+ if err != nil {
1336+ // On most kernels `nr_inodes=1` works fine. However, Ubuntu 20.04 (Focal) with
1337+ // the official 5.4 kernel carries a private patch in "mm/shmem.c" that rejects
1338+ // `nr_inodes<2`, so retry with `nr_inodes=2` here.
1339+ // For reference, search for "case Opt_nr_inodes" in:
1340+ // https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal/plain/mm/shmem.c?h=Ubuntu-5.4.0-216.236
1341+ err = mount ("tmpfs" , path , "tmpfs" , unix .MS_RDONLY , label .FormatMountLabel ("nr_blocks=1,nr_inodes=2" , mountLabel ))
13441342 }
13451343 return err
13461344}
0 commit comments