*: users of get_volume_size_in_bytes() should open their file O_RDWR
No binary (build failed)
—
(log yok)
| @@ -27,6 +27,7 @@ uoff_t FAST_FUNC get_volume_size_in_bytes(int fd, | |
| // Seek past end fails on block devices but works on files! | |
| if (lseek(fd, result - 1, SEEK_SET) != (off_t)-1) { | |
| char dummy; | |
| + | //NB: here, fd needs a O_RDWR open, not O_WRONLY! |
| if (extend && safe_read(fd, &dummy, 1) != 1) { | |
| // the file is shorter | |
| xwrite(fd, "", 1); // grow it | |
| @@ -255,7 +255,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv) | |
| argv += optind; // argv[0] -- device | |
| // open the device, check the device is a block device | |
| - | xmove_fd(xopen(argv[0], O_WRONLY), fd); |
| + | xmove_fd(xopen(argv[0], O_RDWR), fd); |
| xfstat(fd, &st, argv[0]); | |
| if (!S_ISBLK(st.st_mode) && !(option_mask32 & OPT_F)) | |
| bb_error_msg_and_die("%s: not a block device", argv[0]); | |
| @@ -168,7 +168,7 @@ int mkfs_reiser_main(int argc UNUSED_PARAM, char **argv) | |
| argv += optind; // argv[0] -- device | |
| // check the device is a block device | |
| - | fd = xopen(argv[0], O_WRONLY | O_EXCL); |
| + | fd = xopen(argv[0], O_RDWR | O_EXCL); |
| xfstat(fd, &st, argv[0]); | |
| if (!S_ISBLK(st.st_mode) && !(option_mask32 & OPT_f)) | |
| bb_error_msg_and_die("%s: not a block device", argv[0]); | |
| @@ -121,7 +121,7 @@ int mkswap_main(int argc UNUSED_PARAM, char **argv) | |
| getopt32(argv, "^" "L:" "\0" "-1"/*at least one arg*/, &label); | |
| argv += optind; | |
| - | fd = xopen(argv[0], O_WRONLY); |
| + | fd = xopen(argv[0], O_RDWR); |
| /* Figure out how big the device is */ | |
| len = get_volume_size_in_bytes(fd, argv[1], 1024, /*extend:*/ 1); | |