mkfs: only complain about failing stat with -d
mkfs -d is a feature that needs a stat() of the mkfs binary, which often fails (as mkfs is often not invoked with a full path or from the same directory). it makes setup look a bit messy as the error is always printed while installing the system, for each created FS, even though the situation is harmless. This change only complains when the stat is actually needed (-d). Change-Id: I54ac01505aa97c1cbe40456c04a35aed5a7ee953
This commit is contained in:
parent
d12d57dcd8
commit
fd5f2edf35
1 changed files with 15 additions and 17 deletions
|
@ -143,27 +143,11 @@ main(int argc, char *argv[])
|
||||||
int nread, mode, usrid, grpid, ch, extra_space_percent;
|
int nread, mode, usrid, grpid, ch, extra_space_percent;
|
||||||
block_t blocks, maxblocks;
|
block_t blocks, maxblocks;
|
||||||
ino_t inodes, root_inum;
|
ino_t inodes, root_inum;
|
||||||
time_t bin_time;
|
|
||||||
char *token[MAX_TOKENS], line[LINE_LEN], *sfx;
|
char *token[MAX_TOKENS], line[LINE_LEN], *sfx;
|
||||||
struct stat statbuf;
|
|
||||||
struct fs_size fssize;
|
struct fs_size fssize;
|
||||||
|
|
||||||
progname = argv[0];
|
progname = argv[0];
|
||||||
|
|
||||||
/* Get two times, the current time and the mod time of the binary of
|
|
||||||
* mkfs itself. When the -d flag is used, the later time is put into
|
|
||||||
* the i_mtimes of all the files. This feature is useful when
|
|
||||||
* producing a set of file systems, and one wants all the times to be
|
|
||||||
* identical. First you set the time of the mkfs binary to what you
|
|
||||||
* want, then go.
|
|
||||||
*/
|
|
||||||
current_time = time((time_t *) 0); /* time mkfs is being run */
|
|
||||||
if (stat(progname, &statbuf)) {
|
|
||||||
perror("stat of itself");
|
|
||||||
bin_time = current_time; /* provide some default value */
|
|
||||||
} else
|
|
||||||
bin_time = statbuf.st_mtime; /* time when mkfs binary was last modified */
|
|
||||||
|
|
||||||
/* Process switches. */
|
/* Process switches. */
|
||||||
blocks = 0;
|
blocks = 0;
|
||||||
inodes = 0;
|
inodes = 0;
|
||||||
|
@ -199,7 +183,6 @@ main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
dflag = 1;
|
dflag = 1;
|
||||||
current_time = bin_time;
|
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
inodes = strtoul(optarg, (char **) NULL, 0);
|
inodes = strtoul(optarg, (char **) NULL, 0);
|
||||||
|
@ -214,6 +197,21 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
if (argc == optind) usage();
|
if (argc == optind) usage();
|
||||||
|
|
||||||
|
/* Get the current time, set it to the mod time of the binary of
|
||||||
|
* mkfs itself when the -d flag is used. The 'current' time is put into
|
||||||
|
* the i_mtimes of all the files. This -d feature is useful when
|
||||||
|
* producing a set of file systems, and one wants all the times to be
|
||||||
|
* identical. First you set the time of the mkfs binary to what you
|
||||||
|
* want, then go.
|
||||||
|
*/
|
||||||
|
current_time = time((time_t *) 0); /* time mkfs is being run */
|
||||||
|
if(dflag) {
|
||||||
|
struct stat statbuf;
|
||||||
|
if (stat(progname, &statbuf)) {
|
||||||
|
perror("stat of itself");
|
||||||
|
} else current_time = statbuf.st_mtime;
|
||||||
|
}
|
||||||
|
|
||||||
/* Percentage of extra size must be nonnegative.
|
/* Percentage of extra size must be nonnegative.
|
||||||
* It can legitimately be bigger than 100 but has to make some sort of sense.
|
* It can legitimately be bigger than 100 but has to make some sort of sense.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue