+ unsigned long long total;
+ int slink_depth_save;
+ unsigned opt;
+
+ INIT_G();
+
+#if ENABLE_FEATURE_HUMAN_READABLE
+ IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 1024;)
+ IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_unit = 512;)
+ if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
+ G.disp_unit = 512;
+#else
+ IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 1;)
+ /* IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 0;) - G is pre-zeroed */
+#endif
+ G.max_print_depth = INT_MAX;
+
+ /* Note: SUSv3 specifies that -a and -s options cannot be used together
+ * in strictly conforming applications. However, it also says that some
+ * du implementations may produce output when -a and -s are used together.
+ * gnu du exits with an error code in this case. We choose to simply
+ * ignore -a. This is consistent with -s being equivalent to -d 0.
+ */
+#if ENABLE_FEATURE_HUMAN_READABLE
+ opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+";
+ opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth);
+ argv += optind;
+ if (opt & OPT_h_for_humans) {
+ G.disp_unit = 0;
+ }
+ if (opt & OPT_m_mbytes) {
+ G.disp_unit = 1024*1024;
+ }
+ if (opt & OPT_k_kbytes) {
+ G.disp_unit = 1024;
+ }
+#else
+ opt_complementary = "H-L:L-H:s-d:d-s:d+";
+ opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth);
+ argv += optind;
+#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
+ if (opt & OPT_k_kbytes) {
+ G.disp_k = 1;
+ }
+#endif
+#endif
+ if (opt & OPT_H_follow_links) {
+ G.slink_depth = 1;
+ }
+ if (opt & OPT_L_follow_links) {
+ G.slink_depth = INT_MAX;
+ }
+ if (opt & OPT_s_total_norecurse) {
+ G.max_print_depth = 0;