Le 09/11/2013 23:41, Bernhard Reutner-Fischer a écrit :
commit: 
http://git.busybox.net/busybox/commit/?id=140f4e351191d8633fd5bd6dcf38cdcccc1f07cb
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

Also, use the name of the block device we found, not necessarily the one
we got from the user:
fstrim -v /
/dev/sdj: 4711 bytes were trimmed

Signed-off-by: Bernhard Reutner-Fischer <[email protected]>
---
  util-linux/fstrim.c |   13 +++++--------
  1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/util-linux/fstrim.c b/util-linux/fstrim.c
index 2fa457b..00140b3 100644
--- a/util-linux/fstrim.c
+++ b/util-linux/fstrim.c
@@ -60,9 +60,7 @@ int fstrim_main(int argc, char **argv) 
MAIN_EXTERNALLY_VISIBLE;
  int fstrim_main(int argc UNUSED_PARAM, char **argv)
  {
        struct fstrim_range range;
-       char *arg_o;
-       char *arg_l;
-       char *arg_m;
+       char *arg_o, *arg_l, *arg_m, *bd;
        unsigned opts;
        int fd;

@@ -96,16 +94,15 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv)
        if (opts & OPT_m)
                range.minlen = xatoull_sfx(arg_m, fstrim_sfx);

-       if (find_block_device(argv[optind])) {
-               fd = xopen_nonblocking(argv[optind]);
+       bd = find_block_device(*(argv += optind));
+       if (bd) {
+               fd = xopen_nonblocking(bd);
                xioctl(fd, FITRIM, &range);
                if (ENABLE_FEATURE_CLEAN_UP)
                        close(fd);

                if (opts & OPT_v)
-                       printf("%s: %llu bytes were trimmed\n", argv[optind], 
range.len);
+                       printf("%s: %llu bytes were trimmed\n", bd, range.len);
        }
-
        return EXIT_SUCCESS;
  }
-
_______________________________________________
busybox-cvs mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox-cvs

Please revert this patch because bd != argv[optind], in my case: argv[optind] = / (root)
bd = /dev/sdc2

argv[optind] must be a mountpoint (directory)

fstrim -h : Usage: fstrim [Options] <mountpoint>

Thanks

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to