Skip to content

Commit 4110360

Browse files
committed
nilfs-resize: switch singular/plural forms of "segment" in message text
When outputting the number segments in messages, switch between singular and plural forms of string "segment" depending on the count. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
1 parent 0d15f76 commit 4110360

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

sbin/nilfs-resize.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,16 @@ static int nilfs_resize_check_free_space(struct nilfs *nilfs,
458458
+ nrsvsegs;
459459
nbytes = nilfs_resize_calc_size_of_segments(nsegs);
460460
myprintf("Error: the filesystem does not have enough free space.\n"
461-
" At least %llu more segments (%llu bytes) are required.\n",
462-
nsegs, nbytes);
461+
" At least %llu more segment%s (%llu bytes) %s required.\n",
462+
nsegs, nsegs != 1 ? "s" : "", nbytes,
463+
nsegs != 1 ? "are" : "is");
463464
return -1;
464465
} else if (verbose) {
465466
nsegs = sustat.ss_ncleansegs - (sustat.ss_nsegs - newnsegs)
466467
- nrsvsegs;
467468
nbytes = nilfs_resize_calc_size_of_segments(nsegs);
468-
myprintf("%llu free segments (%llu bytes) will be left after shrinkage.\n",
469-
nsegs, nbytes);
469+
myprintf("%llu free segment%s (%llu bytes) will be left after shrinkage.\n",
470+
nsegs, nsegs != 1 ? "s" : "", nbytes);
470471
}
471472
return 0;
472473
}
@@ -1258,8 +1259,10 @@ static int nilfs_shrink_online(struct nilfs *nilfs, const char *device,
12581259
goto out;
12591260

12601261
if (newnsegs < sustat.ss_nsegs) {
1261-
myprintf("%llu segments will be truncated from segnum %llu.\n",
1262-
(unsigned long long)sustat.ss_nsegs - newnsegs,
1262+
uint64_t truncsegs = sustat.ss_nsegs - newnsegs;
1263+
1264+
myprintf("%llu segment%s will be truncated from segnum %llu.\n",
1265+
(unsigned long long)truncsegs, truncsegs != 1 ? "s" : "",
12631266
(unsigned long long)newnsegs);
12641267
} else if (newnsegs == sustat.ss_nsegs) {
12651268
myprintf("No segments will be truncated.\n");

0 commit comments

Comments
 (0)