tls: reorder a few more cipher ids
[oweals/busybox.git] / util-linux / fstrim.c
index 1fbf0c857679be9de61b2da82d44b4618dd2dea2..558a94a9e9b9855dd0544e57ba6021425942627e 100644 (file)
@@ -7,7 +7,6 @@
  *
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
-
 //config:config FSTRIM
 //config:      bool "fstrim (5.5 kb)"
 //config:      default y
@@ -69,11 +68,13 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv)
                "minimum\0"   Required_argument    "m"
                "verbose\0"   No_argument          "v"
                ;
-       applet_long_options = fstrim_longopts;
 #endif
 
-       opt_complementary = "=1"; /* exactly one non-option arg: the mountpoint */
-       opts = getopt32(argv, "o:l:m:v", &arg_o, &arg_l, &arg_m);
+       opts = getopt32long(argv, "^"
+                       "o:l:m:v"
+                       "\0" "=1", fstrim_longopts,
+                       &arg_o, &arg_l, &arg_m
+       );
 
        memset(&range, 0, sizeof(range));
        range.len = ULLONG_MAX;
@@ -86,15 +87,21 @@ int fstrim_main(int argc UNUSED_PARAM, char **argv)
                range.minlen = xatoull_sfx(arg_m, kmg_i_suffixes);
 
        mp = argv[optind];
-       if (find_block_device(mp)) {
+//Wwhy bother checking that it's a blockdev?
+//     if (find_block_device(mp)) {
                fd = xopen_nonblocking(mp);
+
+               /* On ENOTTY error, util-linux 2.31 says:
+                * "fstrim: FILE: the discard operation is not supported"
+                */
                xioctl(fd, FITRIM, &range);
+
                if (ENABLE_FEATURE_CLEAN_UP)
                        close(fd);
 
                if (opts & OPT_v)
                        printf("%s: %llu bytes trimmed\n", mp, (unsigned long long)range.len);
                return EXIT_SUCCESS;
-       }
+//     }
        return EXIT_FAILURE;
 }