123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #include "libbb.h"
- int fallocate_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
- int fallocate_main(int argc UNUSED_PARAM, char **argv)
- {
- const char *str_l;
- const char *str_o = "0";
- off_t ofs, len;
- unsigned opts;
- int fd;
-
- opts = getopt32(argv, "^" "l:o:" "\0" "=1", &str_l, &str_o);
- if (!(opts & 1))
- bb_show_usage();
- ofs = xatoull_sfx(str_o, kmg_i_suffixes);
- len = xatoull_sfx(str_l, kmg_i_suffixes);
- argv += optind;
- fd = xopen3(*argv, O_RDWR | O_CREAT, 0666);
-
-
- if ((errno = posix_fallocate(fd, ofs, len)) != 0)
- bb_perror_msg_and_die("fallocate '%s'", *argv);
-
- return EXIT_SUCCESS;
- }
|