95 Commits

Author SHA1 Message Date
Ryusuke Konishi
5c20d4b068 Use format specifier PRIu32, PRIu64, and dedicated definition PRIcno
Use PRIu32, PRIu64, and PRIcno, which corresponds to the defined type
nilfs_cno_t, for format strings in printf(), etc, and remove type cast
for corresponding arguments if possible.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
2026-01-11 22:48:05 +09:00
Christopher Zimmermann
7aae659498 chcp: fix segfault
reported here:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=715729

Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=715729
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
2025-09-22 09:29:23 +09:00
Ryusuke Konishi
a34ee4f35f bin/*: correct error message for invalid long option specification
The commands under "bin/" output the error messages by themselves by
setting opterr to 0, and are compatible with getopt_long, but if
an invalid long option is specified, the option that causes the error
will not be displayed as shown below:

 lscp: invalid option --

Also lscp and lssu do not properly display error messages for options
that require an additional argument and it is not provided.

Fix these issues by not setting opterr to 0 and leaving error output
for argument options to getopt() or getopt_long()'s built-in features.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
2024-03-03 22:12:04 +09:00
Ryusuke Konishi
45d40b47af nilfs-utils: update maintainer's email address
Update email addresses of NTT developers since lab.ntt.co.jp email
domain has been deprecated due to company policy.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
2019-07-20 13:23:53 +09:00
Kurt Van Dijck
115fe4b976 nilfs-utils: use _POSIX_MAX_INPUT
musl does provide _POSIX_MAX_INPUT, but no MAX_INPUT out of the box.
This commit assigns _POSIX_MAX_INPUT to MAX_INPUT.

Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2018-01-14 18:49:57 +09:00
Ryusuke Konishi
7948e6bab5 nilfs-utils: replace __u32 etc. with standard uint32_t style types
Replace __u64, __u32, __u8, __s64, and __s32 with standard uint64_t,
uint32_t, uint8_t, int64_t and int32_t types, respectively, except for
nilfs2_api.h and nilfs2_ondisk.h.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-10-11 00:41:24 +09:00
Ryusuke Konishi
8bdf8f47c6 libsegment: add sanity checks for per-file summary information
On-disk summary information of files can fall into inconsistent
states in theory:

 - The block count recorded in finfo can exceed the number of
   remaining payload blocks.
 - The number of data blocks recorded in finfo can be larger than the
   number of total blocks of the file, or
 - The total size of finfo and binfo structures can exceed the size of
   summary information of the partial segment.

This adds sanity checks for these glitches to nilfs_file, and adds a
framework to handle these errors as well.

Also, this enhances the error output routine of dumpseg command to
handle these errors nicely.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-30 00:13:14 +09:00
Ryusuke Konishi
66754b6bb7 lib/segment: refactor file/block iterator
Rewrite nilfs_file/nilfs_block structs and their iterators to clarify
them.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-25 22:37:59 +09:00
Ryusuke Konishi
dda3f01166 nilfs-utils: do not use nonsensical term "super file"
The concept of "super file" is very confusing and nonsensical.
Get rid of the term from nilfs-utils.

The term is only used in the name of nilfs_file_is_super() test
function, so this alters the function name.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-22 03:28:19 +09:00
Ryusuke Konishi
823f4234c0 lib/segment: add sanity checks on sizes of partial segment
On-disk sizes recorded in segment summary header can be too short or
too large.

This adds three errors on sizes related to partial segment:

  - partial segment block count
  - segment summary header size, and
  - segment summary information size

and adds their sanity checks to libsegment.

Also, this enhances the error output routine of dumpseg command to
handle these errors nicely.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-20 01:07:38 +09:00
Ryusuke Konishi
14b6af7383 nilfs-utils: use unlikely()/likely() macros
Use likely() and unlikely() macros for condition statements
that determine branching to error-handling.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-19 01:19:18 +09:00
Ryusuke Konishi
3d86295433 lib/segment: handle potential alignment error
If ss_bytes, an on-disk segment summary data, stores a value that is
not a multiple of eight, memory access for reading file/block
information can cause a bad alignment exception depending on the
architecture.

To prevent the issue, this introduces an error handling framework to
the psegment iterator, inserts a sanity check in
nilfs_psegment_is_valid() function that detects the bad alignment
condition and reports it with the framework, and applies these changes
to dumpseg command and gc library.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-18 17:45:57 +09:00
Ryusuke Konishi
ab44ef4352 lib/nilfs: revise nilfs_get_segment() and nilfs_put_segment()
Rewrite nilfs_get_segment() and nilfs_put_segment() so that
nilfs_get_segment() stores related information (segment size, start
block number, number of blocks, memory address, etc) in a new data
structure, nilfs_segment, and nilfs_put_segment() releases the memory
allocated or mapped by nilfs_get_segment() based on the information in
nilfs_segment.

This also simplifies nilfs_psegment struct and functions wrt iterator
for partial segment, that is, nilfs_psegment_init(),
nilfs_psegment_is_end(), nilfs_psegment_next(), and
nilfs_psegment_for_each().

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-18 17:45:57 +09:00
Ryusuke Konishi
68d8b82ded dumpseg: fix misuse of endian conversion macro for ss_nblocks
64-bit endian conversion macro le64_to_cpu() is wrongly used for
32-bit on-disk data (ss_nblocks) at dumpseg_print_psegment() function.
This fixes the bug.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-17 15:34:40 +09:00
Ryusuke Konishi
6aa0531a53 nilfs-utils: move segment i/o routines to an internal library
Add a new header file "segment.h", move definition of segment i/o
routines into it, and move the implementation from libnilfs to a new
internal library libsegment.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-11 18:48:36 +09:00
Ryusuke Konishi
a3ae4b830e nilfs-utils: use nilfs_get_blocks_per_segment()
Remove copy and paste code snippets related to the number of blocks
per segment that repeatedly appear in lib/nilfs.c and dumpseg.c.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-09-04 15:22:36 +09:00
Ryusuke Konishi
73cfaf4822 lssu: use nilfs_cnormap
Use nilfs_cnormap API to calculate the minimum checkpoint
number included in a given protection period.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-08-24 21:31:01 +09:00
Ryusuke Konishi
bb1112c69b lssu: do not mark protected flag for segments with a future timestamp
Prevent marking "p" flag on segments that have a future timestamp in
the output of "lssu -l".

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-08-15 00:35:19 +09:00
Ryusuke Konishi
03ec0cb407 lssu: handle absolute time with signed type variables
Similar fix with the commit d73631931f4b4849 ("cleanerd: handle
absolute time with signed type variables").  Change type of variables
which are used to store a timestamp value.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-08-14 23:59:42 +09:00
Ryusuke Konishi
af2f25112d nilfs-utils: remove unnecessary braces in conditional statement
Fix the following style issue regression that checkpatch detected:

 "WARNING: braces {} are not necessary for any arm of this statement"

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-08-03 00:44:32 +09:00
Ryusuke Konishi
d548d57d9a nilfs-utils: use err(), warn(), and their variants
Replace use of fprintf(stderr, ...) for error output with err(),
errx(), warn(), or warnx() in chcp, dumpseg, lscp, lssu, mkcp, rmcp,
nilfs-tune, and cleanerd.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-08-01 00:07:44 +09:00
Ryusuke Konishi
03af607184 nilfs-utils: use EXIT_SUCCESS and EXIT_FAILURE
Use EXIT_SUCCESS and EXIT_FAILURE macros for exit status to clarify
the meaning of hard coded constants (0 or 1).

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-07-29 00:01:15 +09:00
Ryusuke Konishi
7eca308368 lssu: close nilfs object cleanly in error cases
Fix error handling of lssu_get_protcno() and lssu_print_suinfo() so
that lssu can exit cleanly calling nilfs_close() in error cases.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-07-28 21:48:29 +09:00
Ryusuke Konishi
85e2682667 rmcp: close nilfs object cleanly in error cases
Fix error handling of nilfs_get_cpstat() so that rmcp can exit cleanly
calling nilfs_close() in error cases.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-07-28 21:48:29 +09:00
Ryusuke Konishi
75e22199c1 nilfs-utils: keep code lines short
Shorten or split long lines to avoid the checkpatch warning "WARNING:
line over 80 characters".

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-07-24 02:15:51 +09:00
Ryusuke Konishi
68dc048aa5 nilfs-utils: fix unnecessary line continuations for output messages
Fix the checkpatch.pl warning "WARNING: Avoid unnecessary line
continuations".

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-07-24 02:15:51 +09:00
Ryusuke Konishi
8b4fea3e51 nilfs-utils: add missing line spacing
Clean up checkpatch.pl warning "WARNING: Missing a blank line after
declarations".

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-04-30 01:47:49 +09:00
Ryusuke Konishi
dadf65a4fe nilfs-utils: remove FSF mailing address from GPL notices
As FSF address changed in the past, and can change in the future,
remove the extra paragraph which metions FSF address in comment
headers, and avoid errors of checkpatch.pl.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2016-04-30 01:17:15 +09:00
Ryusuke Konishi
7549a17a17 Remove obsolete email addresses
This removes obsolete email addresses from comment lines.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2015-11-01 23:47:28 +09:00
Ryusuke Konishi
374e2e06e6 lscp: accelerate backward checkpoint listing
If the minimum checkpoint number of valid checkpoints is large to some
extent, "lscp -r" command takes very long time:

 $ lscp -r
                 CNO        DATE     TIME  MODE  FLG      BLKCNT       ICNT
             6541269  2015-02-11 18:38:30   cp    -          435          2
             6541268  2015-02-11 18:38:25   cp    -          484         51
  <the command looks to enter a busy loop>

This is because it tries to find younger checkpoints tracking back the
checkpoint list in a constant step size.

This fixes the issue by lengthening or shortening the step size
depending on whether the backward search found a younger checkpoint or
not.

This patch also inserts a dummy nilfs_get_cpinfo() call before
starting the backward search to make successive nilfs_get_cpinfo()
calls much faster.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2015-02-15 00:39:19 +09:00
Ryusuke Konishi
82d6353c84 lscp: show snapshots, even if marked minor (reverse mode)
Apply the same change as the commit
d04aea7db2281d2f22d1c943dc5791931db8c474 "lscp: always show snapshots,
even if marked minor" for reverse mode.

Cc: Dan McGee <dan@archlinux.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-09-10 05:10:22 +09:00
Dan McGee
d04aea7db2 lscp: always show snapshots, even if marked minor
When the average user types `lscp` and doesn't see the snapshot they
just tried to make, it can be very confusing. Add an additional check
to ensure snapshots are never omitted from lscp output.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-09-03 02:11:44 +09:00
Ryusuke Konishi
fc2fe67724 bin/*: improve error message on failure of nilfs_open()
The error message on failure of nilfs_open() function has two issues
in commands lscp, lssu, mkcp, chcp, rmcp, and dumpseg:

 1) When device name is omitted, a null pointer is passed to a string
    type field of the error message and a broken message is printed as
    below:

      lssu: (null): cannot open NILFS

 2) Description of errno is not shown in the error message.

This fixes these issues.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-08-23 11:45:01 +09:00
Ryusuke Konishi
382e36b58b nilfs-utils: fix typos in messages
Fix typos in messages of nilfs-resize command, lssu command, and
libnilfsgc.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-04-20 00:02:36 +09:00
Ryusuke Konishi
d5ed126378 lssu: fix format-security warning at lssu_print_header()
Fix the following gcc warning on some platforms:

 lssu.c: In function 'lssu_print_header':
 lssu.c:127:2: warning: format not a string literal and no format arguments [-Wformat-security]
   printf(lssu_format[disp_mode].header);
   ^

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-15 14:04:37 +09:00
Ryusuke Konishi
e131a9ebe5 nilfs-utils: do not initialize static or global variables to 0 or NULL
Fix the following checkpatch errors:

 ERROR: do not initialise statics to 0 or NULL
 #92: FILE: lscp.c:92:
 +static int show_all = 0;

 ERROR: do not initialise statics to 0 or NULL
 #82: FILE: rmcp.c:82:
 +static int force = 0;

 ERROR: do not initialise statics to 0 or NULL
 #83: FILE: rmcp.c:83:
 +static int interactive = 0;

 ERROR: do not initialise statics to 0 or NULL
 #108: FILE: mkfs/mkfs.c:108:
 +static int quiet = 0;

 ERROR: do not initialise statics to 0 or NULL
 #109: FILE: mkfs/mkfs.c:109:
 +static int cflag = 0;

 ERROR: do not initialise statics to 0 or NULL
 #110: FILE: mkfs/mkfs.c:110:
 +static int nflag = 0;

 ERROR: do not initialise statics to 0 or NULL
 #111: FILE: mkfs/mkfs.c:111:
 +static int verbose = 0;

 ERROR: do not initialise statics to 0 or NULL
 #113: FILE: mkfs/mkfs.c:113:
 +static int force_overwrite = 0;

 ERROR: do not initialise statics to 0 or NULL
 #118: FILE: mkfs/mkfs.c:118:
 +static time_t creation_time = 0;

 ERROR: do not initialise statics to 0 or NULL
 #236: FILE: mkfs/mkfs.c:236:
 +static void **disk_buffer = NULL;

 ERROR: do not initialise statics to 0 or NULL
 #54: FILE: mount/fstab.c:54:
 +static int have_mtab_info = 0;

 ERROR: do not initialise statics to 0 or NULL
 #55: FILE: mount/fstab.c:55:
 +static int var_mtab_does_not_exist = 0;

 ERROR: do not initialise statics to 0 or NULL
 #56: FILE: mount/fstab.c:56:
 +static int var_mtab_is_a_symlink = 0;

 ERROR: do not initialise statics to 0 or NULL
 #108: FILE: mount/fstab.c:108:
 +static int got_mtab = 0;

 ERROR: do not initialise statics to 0 or NULL
 #109: FILE: mount/fstab.c:109:
 +static int got_fstab = 0;

 ERROR: do not initialise statics to 0 or NULL
 #327: FILE: mount/fstab.c:327:
 +static int we_created_lockfile = 0;

 ERROR: do not initialise statics to 0 or NULL
 #331: FILE: mount/fstab.c:331:
 +static int signals_have_been_setup = 0;

 ERROR: do not initialise globals to 0 or NULL
 #97: FILE: mount/mount.nilfs2.c:97:
 +int verbose = 0;

 ERROR: do not initialise globals to 0 or NULL
 #98: FILE: mount/mount.nilfs2.c:98:
 +int mount_quiet = 0;

 ERROR: do not initialise globals to 0 or NULL
 #99: FILE: mount/mount.nilfs2.c:99:
 +int readonly = 0;

 ERROR: do not initialise globals to 0 or NULL
 #100: FILE: mount/mount.nilfs2.c💯
 +int readwrite = 0;

 ERROR: do not initialise statics to 0 or NULL
 #101: FILE: mount/mount.nilfs2.c:101:
 +static int nomtab = 0;

 ERROR: do not initialise statics to 0 or NULL
 #102: FILE: mount/mount.nilfs2.c:102:
 +static int devro = 0;

 ERROR: do not initialise statics to 0 or NULL
 #103: FILE: mount/mount.nilfs2.c:103:
 +static int fake = 0;

 ERROR: do not initialise globals to 0 or NULL
 #90: FILE: mount/mount_libmount.c:90:
 +int mount_quiet = 0;   /* for sundries.c */

 ERROR: do not initialise statics to 0 or NULL
 #91: FILE: mount/mount_libmount.c:91:
 +static int verbose = 0;

 ERROR: do not initialise statics to 0 or NULL
 #92: FILE: mount/mount_libmount.c:92:
 +static int devro = 0;

 ERROR: do not initialise statics to 0 or NULL
 #94: FILE: mount/mount_libmount.c:94:
 +static char *mount_fstype = NULL;

 ERROR: do not initialise globals to 0 or NULL
 #98: FILE: mount/umount.nilfs2.c:98:
 +int verbose = 0;

 ERROR: do not initialise globals to 0 or NULL
 #99: FILE: mount/umount.nilfs2.c:99:
 +int mount_quiet = 0;

 ERROR: do not initialise globals to 0 or NULL
 #100: FILE: mount/umount.nilfs2.c💯
 +int readonly = 0;

 ERROR: do not initialise globals to 0 or NULL
 #101: FILE: mount/umount.nilfs2.c:101:
 +int readwrite = 0;

 ERROR: do not initialise statics to 0 or NULL
 #102: FILE: mount/umount.nilfs2.c:102:
 +static int nomtab = 0;

 ERROR: do not initialise globals to 0 or NULL
 #82: FILE: mount/umount_libmount.c:82:
 +int mount_quiet = 0;   /* for sundries.c */

 ERROR: do not initialise statics to 0 or NULL
 #83: FILE: mount/umount_libmount.c:83:
 +static int verbose = 0;

 ERROR: do not initialise statics to 0 or NULL
 #84: FILE: mount/umount_libmount.c:84:
 +static int force = 0;

 ERROR: do not initialise statics to 0 or NULL
 #85: FILE: mount/umount_libmount.c:85:
 +static int suid = 0;   /* reserved for non-root user mount/umount

 ERROR: do not initialise statics to 0 or NULL
 #125: FILE: nilfs-clean/nilfs-clean.c:125:
 +static int show_version_only = 0;

 ERROR: do not initialise statics to 0 or NULL
 #126: FILE: nilfs-clean/nilfs-clean.c:126:
 +static int verbose = 0;

 ERROR: do not initialise statics to 0 or NULL
 #128: FILE: nilfs-clean/nilfs-clean.c:128:
 +static const char *conffile = NULL;

 ERROR: do not initialise statics to 0 or NULL
 #105: FILE: nilfs-resize/nilfs-resize.c:105:
 +static int show_version_only = 0;

 ERROR: do not initialise statics to 0 or NULL
 #106: FILE: nilfs-resize/nilfs-resize.c:106:
 +static int verbose = 0;

 ERROR: do not initialise statics to 0 or NULL
 #107: FILE: nilfs-resize/nilfs-resize.c:107:
 +static int assume_yes = 0;

 ERROR: do not initialise statics to 0 or NULL
 #143: FILE: nilfs-resize/nilfs-resize.c:143:
 +static int pm_in_progress = 0;  /* 0: off, 1: on, -1: interrupted */

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-14 00:46:01 +09:00
Ryusuke Konishi
9f15884b46 nilfs-utils: do not indent labels
Fix the following checkpatch warnings:

 WARNING: labels should not be indented
 #218: FILE: lssu.c:218:
 +               skip_scan:

 WARNING: labels should not be indented
 #1565: FILE: cleanerd/cleanerd.c:1565:
 +       sleep:

 WARNING: labels should not be indented
 #58: FILE: mount/mount_mntent.c:58:
 +       next:

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-14 00:06:52 +09:00
Ryusuke Konishi
73a38a6c55 nilfs-utils: insert backslash between lines splitting quoted string
Fix the following checkpatch warnings:

 WARNING: quoted string split across lines
 #97: FILE: lscp.c:97:
 +       printf("                 CNO        DATE     TIME  MODE  FLG     %s"
 +              "       ICNT\n",

 WARNING: quoted string split across lines
 #257: FILE: cleaner_ctl.c:257:
 +                                    _("Error: no valid nilfs mountpoint "
 +                                      "found."));

 WARNING: quoted string split across lines
 #308: FILE: cleaner_ctl.c:308:
 +                                    _("Error: cannot create receive queue: "
 +                                      "%s."),

 WARNING: quoted string split across lines
 #338: FILE: cleaner_ctl.c:338:
 +                                            _("Error: cannot open cleaner on "
 +                                              "%s: %s."),

 WARNING: quoted string split across lines
 #290: FILE: cleaner_exec.c:290:
 +       nilfs_cleaner_printf(_("cleanerd (pid=%ld) still exists on %d. "
 +                              "waiting."),

 WARNING: quoted string split across lines
 #380: FILE: cleanerd/cleanerd.c:380:
 +               syslog(LOG_ERR, "failed to create checkpoint number converter "
 +                      ": %m");

 WARNING: quoted string split across lines
 #1397: FILE: cleanerd/cleanerd.c:1397:
 +               syslog(LOG_ERR, "cannot convert protection time to checkpoint "
 +                      "number: %m");

 WARNING: quoted string split across lines
 #730: FILE: mkfs/mkfs.c:730:
 +                       perr("Error: %s is currently mounted. "
 +                            "You cannot make a filesystem on this device.",

 WARNING: quoted string split across lines
 #772: FILE: mkfs/mkfs.c:772:
 +                               pinfo("WARNING: Device %s appears to contain "
 +                                       "an existing %s superblock.",

 WARNING: quoted string split across lines
 #777: FILE: mkfs/mkfs.c:777:
 +                               pinfo("WARNING: Device %s appears to contain "
 +                                       "an partition table (%s).",

 WARNING: quoted string split across lines
 #782: FILE: mkfs/mkfs.c:782:
 +                                       pinfo("Device %s appears to contain "
 +                                               "something weird.", device);

 WARNING: quoted string split across lines
 #860: FILE: mkfs/mkfs.c:860:
 +               perr("Internal error: illegal disk buffer access "
 +                    "(blocknr=%llu)", blocknr);

 WARNING: quoted string split across lines
 #946: FILE: mkfs/mkfs.c:946:
 +                               pinfo("Discard succeeded and will return 0s "
 +                                     " - skip wiping");

 WARNING: quoted string split across lines
 #206: FILE: mount/fstab.c:206:
 +                       printf (_("mount: could not open %s - "
 +                                 "using %s instead\n"),

 WARNING: quoted string split across lines
 #434: FILE: mount/fstab.c:434:
 +               die (EX_FILEIO, _("can't create lock file %s: %s "
 +                                                 "(use -n flag to override)"),

 WARNING: quoted string split across lines
 #460: FILE: mount/fstab.c:460:
 +                       die (EX_FILEIO, _("can't link lock file %s: %s "
 +                            "(use -n flag to override)"),

 WARNING: quoted string split across lines
 #476: FILE: mount/fstab.c:476:
 +                       die (EX_FILEIO, _("can't open lock file %s: %s "
 +                            "(use -n flag to override)"),

 WARNING: quoted string split across lines
 #430: FILE: mount/mount.nilfs2.c:430:
 +               error(_("%s: the device already has a rw-mount on %s."
 +                       "\n\t\tmultiple rw-mount is not allowed."),

 WARNING: quoted string split across lines
 #446: FILE: mount/mount.nilfs2.c:446:
 +                       error(_("%s: remount failed due to %s shutdown "
 +                               "failure"), progname, NILFS_CLEANERD_NAME);

 WARNING: quoted string split across lines
 #301: FILE: mount/mount_libmount.c:301:
 +               error(_("%s: the device already has a rw-mount on %s."
 +                       "\n\t\tmultiple rw-mount is not allowed."),

 WARNING: quoted string split across lines
 #324: FILE: mount/mount_libmount.c:324:
 +                       error(_("%s: different mount point (%s). "
 +                               "remount failed."),

 WARNING: quoted string split across lines
 #334: FILE: mount/mount_libmount.c:334:
 +                               error(_("%s: remount failed due to %s "
 +                                       "shutdown failure"), progname,

 WARNING: quoted string split across lines
 #182: FILE: mount/mount_mntent.c:182:
 +                               fprintf(stderr, _("[mntent]: warning: no final "
 +                                       "newline at the end of %s\n"),

 WARNING: quoted string split across lines
 #466: FILE: nilfs-clean/nilfs-clean.c:466:
 +                               myprintf(_("Error: invalid protection period: "
 +                                          "%s\n"), optarg);

 WARNING: quoted string split across lines
 #353: FILE: nilfs-resize/nilfs-resize.c:353:
 +               myprintf("Error: the filesystem does not have enough free "
 +                        "space.\n"

 WARNING: quoted string split across lines
 #362: FILE: nilfs-resize/nilfs-resize.c:362:
 +               myprintf("%llu free segments (%llu bytes) will be left "
 +                        "after shrinkage.\n", nsegs, nbytes);

 WARNING: quoted string split across lines
 #393: FILE: nilfs-resize/nilfs-resize.c:393:
 +                       myprintf("Error: operation failed during searching "
 +                                "movable segments: %s\n", strerror(errno));

 WARNING: quoted string split across lines
 #430: FILE: nilfs-resize/nilfs-resize.c:430:
 +                       myprintf("Error: operation failed during searching "
 +                                "latest segment: %s\n", strerror(errno));

 WARNING: quoted string split across lines
 #468: FILE: nilfs-resize/nilfs-resize.c:468:
 +                       myprintf("Error: operation failed during searching "
 +                                "active segments: %s\n", strerror(errno));

 WARNING: quoted string split across lines
 #499: FILE: nilfs-resize/nilfs-resize.c:499:
 +                       myprintf("Error: operation failed during searching "
 +                                "in-use segments: %s\n", strerror(errno));

 WARNING: quoted string split across lines
 #529: FILE: nilfs-resize/nilfs-resize.c:529:
 +                       myprintf("Error: operation failed during counting "
 +                                "in-use segments: %s\n", strerror(errno));

 WARNING: quoted string split across lines
 #725: FILE: nilfs-resize/nilfs-resize.c:725:
 +                       myprintf("Error: Failed to move active segments -- "
 +                                "give up.\n");

 WARNING: quoted string split across lines
 #752: FILE: nilfs-resize/nilfs-resize.c:752:
 +               myprintf("Error: Confused. Number of segments became larger "
 +                        "than requested size.\n");

 WARNING: quoted string split across lines
 #798: FILE: nilfs-resize/nilfs-resize.c:798:
 +                       myprintf("Error: operation failed during moving "
 +                                "in-use segments: %s\n", strerror(errno));

 WARNING: quoted string split across lines
 #866: FILE: nilfs-resize/nilfs-resize.c:866:
 +               myprintf("%llu segments will be truncated from "
 +                        "segnum %llu.\n",

 WARNING: quoted string split across lines
 #873: FILE: nilfs-resize/nilfs-resize.c:873:
 +               myprintf("Error: Confused. Number of segments "
 +                        "became larger than requested size:\n"

 WARNING: quoted string split across lines
 #888: FILE: nilfs-resize/nilfs-resize.c:888:
 +                       myprintf("       This kernel does not support the "
 +                                "set allocation range API.\n");

 WARNING: quoted string split across lines
 #940: FILE: nilfs-resize/nilfs-resize.c:940:
 +                       myprintf("In-use segment found again. "
 +                                "will retry moving them.. (retry = %d)\n",

 WARNING: quoted string split across lines
 #1175: FILE: nilfs-resize/nilfs-resize.c:1175:
 +                       myprintf("Error: size larger than partition "
 +                                "size (%llu bytes).\n", devsize);

 WARNING: quoted string split across lines
 #1190: FILE: nilfs-resize/nilfs-resize.c:1190:
 +                       myprintf("size %llu is not alinged to sector "
 +                                "size. truncated to %llu.\n",

 WARNING: quoted string split across lines
 #1201: FILE: nilfs-resize/nilfs-resize.c:1201:
 +               myprintf("Error: %s is not currently mounted. Offline resising"
 +                        "\n"

 WARNING: quoted string split across lines
 #288: FILE: nilfs-tune/nilfs-tune.c:288:
 +       sprintf(buf, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
 +               "%02x%02x-%02x%02x%02x%02x%02x%02x", uuid[0], uuid[1],

 WARNING: quoted string split across lines
 #527: FILE: nilfs-tune/nilfs-tune.c:527:
 +               fprintf(stderr, "Warning: %s: unknown incompatible "
 +                       "features: 0x%llx\n", device, features);

 WARNING: quoted string split across lines
 #533: FILE: nilfs-tune/nilfs-tune.c:533:
 +               fprintf(stderr, "Warning: %s: unknown read-only compatible "
 +                       "features: 0x%llx\n", device, features);

 WARNING: quoted string split across lines
 #591: FILE: nilfs-tune/nilfs-tune.c:591:
 +               fprintf(stderr, "ERROR: %s is currently mounted.  "
 +                       "Aborting execution.\n"

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-14 00:02:02 +09:00
Ryusuke Konishi
1125f0dde0 nilfs-utils: fix order of storage class specifiers
Fix the following checkpatch warnings:

 WARNING: storage class should be at the beginning of the declaration
 #54: FILE: dumpseg.c:54:
 +const static struct option long_option[] = {

 WARNING: storage class should be at the beginning of the declaration
 #57: FILE: lscp.c:57:
 +const static struct option long_option[] = {

 WARNING: storage class should be at the beginning of the declaration
 #61: FILE: lssu.c:61:
 +const static struct option long_option[] = {

 WARNING: storage class should be at the beginning of the declaration
 #100: FILE: lssu.c💯
 +const static struct lssu_format lssu_format[] = {

 WARNING: storage class should be at the beginning of the declaration
 #53: FILE: mkcp.c:53:
 +const static struct option long_option[] = {

 WARNING: storage class should be at the beginning of the declaration
 #57: FILE: rmcp.c:57:
 +const static struct option long_options[] = {

 WARNING: storage class should be at the beginning of the declaration
 #85: FILE: nilfs-tune/nilfs-tune.c:85:
 +const static __u64 ok_features[NILFS_MAX_FEATURE_TYPES] = {

 WARNING: storage class should be at the beginning of the declaration
 #94: FILE: nilfs-tune/nilfs-tune.c:94:
 +const static __u64 clear_ok_features[NILFS_MAX_FEATURE_TYPES] = {

 WARNING: storage class should be at the beginning of the declaration
 #96: FILE: cleanerd/cleanerd.c:96:
 +const static struct option long_option[] = {

 WARNING: storage class should be at the beginning of the declaration
 #1060: FILE: mkfs/mkfs.c:1060:
 +const static __u64 ok_features[NILFS_MAX_FEATURE_TYPES] = {

 WARNING: storage class should be at the beginning of the declaration
 #70: FILE: nilfs-clean/nilfs-clean.c:70:
 +const static struct option long_option[] = {

 WARNING: storage class should be at the beginning of the declaration
 #72: FILE: nilfs-resize/nilfs-resize.c:72:
 +const static struct option long_option[] = {

 WARNING: storage class should be at the beginning of the declaration
 #144: FILE: nilfs-resize/nilfs-resize.c:144:
 +const static char *pm_label;

 WARNING: storage class should be at the beginning of the declaration
 #707: FILE: nilfs-resize/nilfs-resize.c:707:
 +       const static struct timespec retry_interval = { 0, 500000000 };

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-14 00:02:02 +09:00
Ryusuke Konishi
c0c8574698 nilfs-utils: use min_t() and max_t()
Simplify some calculations in lssu, lscp, lib/gc.c, lib/nilfs.c,
lib/cnoconv.c, and cleanerd with min_t() and max_t().

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-12 01:16:08 +09:00
Ryusuke Konishi
4a43f52f42 lssu: display a "p" flag on protected segments
Display a "p" flag in STAT field of the output lines of protected
segments when -l (--latest-usage) option is specfied.  This flag
clarifies which segments are protected by garbage collection at that
moment.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-11 20:20:25 +09:00
Ryusuke Konishi
fdde7042c4 lssu: fix protection period option
Fix a bug of nilfs_get_latest_usage() function which blocks the
protection period specified with -p option from being passed to
nilfs_assess_segment() function and results in incorrect output of
live block counts.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-11 12:07:23 +09:00
Ryusuke Konishi
9b5f6a1848 lssu: add option to print count of live blocks
This adds new options "-l" and "-p" to lssu command.

"-l" option prints count and ratio of live blocks for in-use segments,
and "-p" option allows users to specify a protection period which is
used to judge whether blocks are live or not.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-10 03:25:39 +09:00
Ryusuke Konishi
c65dc59459 nilfs-utils: renew parser library
This renames checkpoint number library "lib/cno.c" to "lib/parser.c",
and moves a parser routine of a protection period option included in
nilfs-clean.c into parser.c to make it available from other programs.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-02-10 02:26:20 +09:00
Ryusuke Konishi
66cfa1c998 lscp: show block count by default
For each checkpoint of NILFS2, total block count (BLKCNT) is more
meaningful information than appended block count (NBLKINC).  This
changes the default display information of lscp command on block count
to BLKCNT from NBLKINC, and updates relevant man pages.  NBLKINC can
be still displayed when we specified '-g' option.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-01-27 02:59:58 +09:00
Ryusuke Konishi
9de0794363 nilfs-utils: fix build of dist archives
The following files are missing in the archive files generated by
"make dist-*":

 - .gitignore files
 - autogen.sh script
 - checkpatch.pl script

This fixes the issue.

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2014-01-27 02:53:24 +09:00
Ryusuke Konishi
9948937162 nilfs-utils: do not use assignment in if condition
This fixes the following checkpatch errors:

 ERROR: do not use assignment in if condition
 #147: FILE: bin/rmcp.c:147:
 +       if ((progname = strrchr(argv[0], '/')) == NULL)

 ERROR: do not use assignment in if condition
 #85: FILE: bin/mkcp.c:85:
 +       if ((progname = strrchr(argv[0], '/')) == NULL)

 ERROR: do not use assignment in if condition
 #183: FILE: bin/dumpseg.c:183:
 +       if ((progname = strrchr(argv[0], '/')) == NULL)

 ERROR: do not use assignment in if condition
 #239: FILE: bin/dumpseg.c:239:
 +               if ((segsize = nilfs_get_segment(nilfs, segnum, &seg)) < 0) {

 ERROR: do not use assignment in if condition
 #90: FILE: bin/chcp.c:90:
 +       if ((progname = strrchr(argv[0], '/')) == NULL)

 ERROR: do not use assignment in if condition
 #306: FILE: lib/gc.c:306:
 +               if ((n = nilfs_get_vinfo(nilfs, vinfo, j)) < 0)

 ERROR: do not use assignment in if condition
 #345: FILE: lib/gc.c:345:
 +               if ((n = nilfs_get_cpinfo(

 ERROR: do not use assignment in if condition
 #465: FILE: lib/gc.c:465:
 +       if ((n = nilfs_get_snapshot(nilfs, &ss)) < 0)

 ERROR: do not use assignment in if condition
 #559: FILE: lib/gc.c:559:
 +               if ((n = nilfs_get_bdescs(nilfs, bdescs + i, count)) < 0)

 ERROR: do not use assignment in if condition
 #127: FILE: lib/nilfs.c:127:
 +               if ((q = strchr(p, MNTOPT_SEP)) != NULL) {

 ERROR: do not use assignment in if condition
 #248: FILE: lib/nilfs.c:248:
 +       if ((pagesize = sysconf(_SC_PAGESIZE)) < 0)

 ERROR: do not use assignment in if condition
 #668: FILE: lib/nilfs.c:668:
 +       if (((ret = ioctl(nilfs->n_iocfd, NILFS_IOCTL_SYNC, cnop)) < 0) &&

 ERROR: do not use assignment in if condition
 #742: FILE: lib/nilfs.c:742:
 +               if ((segment = mmap(0, segsize, PROT_READ, MAP_SHARED,

 ERROR: do not use assignment in if condition
 #747: FILE: lib/nilfs.c:747:
 +               if ((segment = malloc(segsize)) == NULL)

 ERROR: do not use assignment in if condition
 #42: FILE: lib/vector.c:42:
 +       if ((vector = malloc(sizeof(struct nilfs_vector))) == NULL)

 ERROR: do not use assignment in if condition
 #45: FILE: lib/vector.c:45:
 +       if ((vector->v_data = malloc(elemsize * NILFS_VECTOR_INIT_MAXELEMS)) == NULL) {

 ERROR: do not use assignment in if condition
 #91: FILE: lib/vector.c:91:
 +               if ((data = realloc(vector->v_data,

 ERROR: do not use assignment in if condition
 #622: FILE: sbin/mkfs/mkfs.c:622:
 +       if ((fd = open(device, O_RDWR)) < 0)

 ERROR: do not use assignment in if condition
 #1059: FILE: sbin/mkfs/mkfs.c:1059:
 +               if ((cbufp = rindex(cbuf, '\n')) != NULL)

 ERROR: do not use assignment in if condition
 #1152: FILE: sbin/nilfs-resize/nilfs-resize.c:1152:
 +       if ((progname = strrchr(argv[0], '/')) != NULL)

 ERROR: do not use assignment in if condition
 #685: FILE: sbin/cleanerd/cldconfig.c:685:
 +       if ((fp = fopen(conffile, "r")) == NULL)

 ERROR: do not use assignment in if condition
 #695: FILE: sbin/cleanerd/cldconfig.c:695:
 +               if ((ntoks = tokenize(line, tokens, NTOKENS_MAX)) == 0)

 ERROR: do not use assignment in if condition
 #697: FILE: sbin/cleanerd/cldconfig.c:697:
 +               if ((ret = nilfs_cldconfig_handle_keyword(

 ERROR: do not use assignment in if condition
 #584: FILE: sbin/cleanerd/cleanerd.c:584:
 +       if ((smv = nilfs_vector_create(sizeof(struct nilfs_segimp))) == NULL)

 ERROR: do not use assignment in if condition
 #606: FILE: sbin/cleanerd/cleanerd.c:606:
 +               if ((n = nilfs_get_suinfo(nilfs, segnum, si, count)) < 0) {

 ERROR: do not use assignment in if condition
 #611: FILE: sbin/cleanerd/cleanerd.c:611:
 +                       if (nilfs_suinfo_reclaimable(&si[i]) &&

 ERROR: do not use assignment in if condition
 #660: FILE: sbin/cleanerd/cleanerd.c:660:
 +               if ((pid = fork()) < 0)

 ERROR: do not use assignment in if condition
 #310: FILE: sbin/mount/fstab.c:310:
 +               if ((opts = mc->m.mnt_opts) != NULL

 ERROR: do not use assignment in if condition
 #278: FILE: sbin/mount/umount.nilfs2.c:278:
 +       if ((fd = open (device, O_RDONLY)) < 0) {

 ERROR: do not use assignment in if condition
 #391: FILE: sbin/mount/umount.nilfs2.c:391:
 +               if (!read_only_mount_point(mc) &&

 ERROR: do not use assignment in if condition
 #471: FILE: sbin/mount/umount.nilfs2.c:471:
 +                       if ((mc = getmntoptfile (spec)) != NULL)

 ERROR: do not use assignment in if condition
 #494: FILE: sbin/nilfs-clean/nilfs-clean.c:494:
 +       if ((progname = strrchr(argv[0], '/')) != NULL)

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2013-12-01 22:11:55 +09:00
Ryusuke Konishi
11227f28fb nilfs-utils: fix coding style issues: space required after that ','
This fixes the following coding style issues:

 ERROR: space required after that ',' (ctx:VxV)
 #51: FILE: bin/lssu.c:51:
 +       {"index",required_argument, NULL, 'i'},
                 ^
 ERROR: space required after that ',' (ctx:VxV)
 #52: FILE: bin/lssu.c:52:
 +       {"lines",required_argument, NULL, 'n'},
                 ^
 ERROR: space required after that ',' (ctx:VxV)
 #88: FILE: sbin/mkfs/mkfs.c:88:
 +#define ROUNDUP_DIV(n,m)   (((n) - 1) / (m) + 1)
                       ^
 ERROR: space required after that ',' (ctx:VxV)
 #89: FILE: sbin/mkfs/mkfs.c:89:
 +#define max_t(type,x,y) \
                   ^
 ERROR: space required after that ',' (ctx:VxV)
 #89: FILE: sbin/mkfs/mkfs.c:89:
 +#define max_t(type,x,y) \
                      ^
 ERROR: space required after that ',' (ctx:VxV)
 #307: FILE: sbin/mkfs/mkfs.c:307:
 +#define BLKDISCARD     _IO(0x12,119)
                                ^
 ERROR: space required after that ',' (ctx:VxV)
 #311: FILE: sbin/mkfs/mkfs.c:311:
 +#define BLKDISCARDZEROES _IO(0x12,124)
                                  ^
 ERROR: space required after that ',' (ctx:VxV)
 #19: FILE: sbin/mkfs/bitops.c:19:
 +int ext2fs_set_bit(int nr,void * addr)
                          ^
 ERROR: space required after that ',' (ctx:VxV)
 #55: FILE: sbin/mkfs/mkfs.h:55:
 +extern int ext2fs_set_bit(int nr,void * addr);
                                  ^
 ...

Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2013-12-01 17:22:56 +09:00
Takashi Iwai
04c35dc0e6 nilfs-utils: Add --print option to mkcp
This patch adds a new option -p|--print to mkcp so that user can know
the CP number it created without checking lscp.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2012-07-24 23:15:31 +09:00
Ryusuke Konishi
9db0e6f069 nilfs-utils: update copyright notices
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
2012-03-18 23:51:06 +09:00