Fix issues in oxfstool format caused by new error handling
This commit is contained in:
@@ -69,7 +69,7 @@ ox::std::uint64_t bytes(const char *str) {
|
|||||||
|
|
||||||
int format(int argc, char **args) {
|
int format(int argc, char **args) {
|
||||||
printf("Creating file system...\n");
|
printf("Creating file system...\n");
|
||||||
auto err = 1;
|
auto err = 0;
|
||||||
if (argc >= 5) {
|
if (argc >= 5) {
|
||||||
auto type = ox::std::atoi(args[2]);
|
auto type = ox::std::atoi(args[2]);
|
||||||
auto size = bytes(args[3]);
|
auto size = bytes(args[3]);
|
||||||
@@ -81,9 +81,10 @@ int format(int argc, char **args) {
|
|||||||
|
|
||||||
if (size < sizeof(FileStore64)) {
|
if (size < sizeof(FileStore64)) {
|
||||||
err = 1;
|
err = 1;
|
||||||
|
fprintf(stderr, "File system size %llu too small, must be at least %lu\n", size, sizeof(FileStore64));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (!err) {
|
||||||
// format
|
// format
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 16:
|
case 16:
|
||||||
@@ -99,16 +100,16 @@ int format(int argc, char **args) {
|
|||||||
err = 1;
|
err = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (!err) {
|
||||||
auto file = fopen(path, "wb");
|
auto file = fopen(path, "wb");
|
||||||
if (file) {
|
if (file) {
|
||||||
err = fwrite(buff, size, 1, file);
|
err = fwrite(buff, size, 1, file) != 1;
|
||||||
err |= fclose(file);
|
err |= fclose(file);
|
||||||
if (err) {
|
if (err) {
|
||||||
printf("Could not write to file: %s.\n", path);
|
fprintf(stderr, "Could not write to file: %s.\n", path);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("Could not open file: %s.\n", path);
|
fprintf(stderr, "Could not open file: %s.\n", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +117,7 @@ int format(int argc, char **args) {
|
|||||||
free(buff);
|
free(buff);
|
||||||
|
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
printf("Created file system %s\n", path);
|
fprintf(stderr, "Created file system %s\n", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user