mirror of
https://github.com/AltraMayor/f3.git
synced 2025-08-03 10:35:57 -04:00
f3read, f3write: chdir(2) to source/target dir
This makes the dir non-umount-able for the program's lifetime.
This commit is contained in:
parent
1aff91a44a
commit
0acac543f1
2
f3read.c
2
f3read.c
@ -434,6 +434,8 @@ int main(int argc, char **argv)
|
||||
argp_parse(&argp, argc, argv, 0, NULL, &args);
|
||||
print_header(stdout, "read");
|
||||
|
||||
adjust_dev_path(&args.dev_path);
|
||||
|
||||
files = ls_my_files(args.dev_path, args.start_at, args.end_at);
|
||||
|
||||
iterate_files(args.dev_path, files, args.start_at, args.end_at,
|
||||
|
@ -368,6 +368,8 @@ int main(int argc, char **argv)
|
||||
argp_parse(&argp, argc, argv, 0, NULL, &args);
|
||||
print_header(stdout, "write");
|
||||
|
||||
adjust_dev_path(&args.dev_path);
|
||||
|
||||
unlink_old_files(args.dev_path, args.start_at, args.end_at);
|
||||
|
||||
return fill_fs(args.dev_path, args.start_at, args.end_at,
|
||||
|
12
utils.c
12
utils.c
@ -18,10 +18,20 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "version.h"
|
||||
#include "utils.h"
|
||||
|
||||
void adjust_dev_path(const char **dev_path)
|
||||
{
|
||||
if (chdir(*dev_path)) {
|
||||
err(errno, "Can't change working directory to %s at %s()", *dev_path, __func__);
|
||||
}
|
||||
|
||||
*dev_path = ".";
|
||||
}
|
||||
|
||||
const char *adjust_unit(double *ptr_bytes)
|
||||
{
|
||||
const char *units[] = { "Byte", "KB", "MB", "GB", "TB", "PB", "EB" };
|
||||
@ -216,8 +226,6 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
|
||||
|
||||
#if (__APPLE__ && __MACH__) || defined(__OpenBSD__)
|
||||
|
||||
#include <unistd.h> /* For usleep(). */
|
||||
|
||||
void msleep(double wait_ms)
|
||||
{
|
||||
assert(!usleep(wait_ms * 1000));
|
||||
|
Loading…
x
Reference in New Issue
Block a user