diff options
author | Ron Yorston <rmy@pobox.com> | 2018-02-13 09:44:44 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-02-13 09:44:44 +0000 |
commit | dc19a361bd6c6df30338371532691bbc7f7126bb (patch) | |
tree | 1fb2cd646d54b5f8e425c4f11f3e09fc21d1966b /util-linux | |
parent | 096aee2bb468d1ab044de36e176ed1f6c7e3674d (diff) | |
parent | 3459024bf404af814cacfe90a0deb719e282ae62 (diff) | |
download | busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.tar.gz busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.tar.bz2 busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/cal.c | 3 | ||||
-rw-r--r-- | util-linux/chrt.c | 55 | ||||
-rw-r--r-- | util-linux/fdisk_gpt.c | 2 | ||||
-rw-r--r-- | util-linux/renice.c | 15 | ||||
-rw-r--r-- | util-linux/umount.c | 4 | ||||
-rw-r--r-- | util-linux/volume_id/lfs.c | 62 | ||||
-rw-r--r-- | util-linux/volume_id/volume_id.c | 3 | ||||
-rw-r--r-- | util-linux/volume_id/volume_id_internal.h | 2 |
8 files changed, 110 insertions, 36 deletions
diff --git a/util-linux/cal.c b/util-linux/cal.c index 10df0ae8b..a4a20d5f0 100644 --- a/util-linux/cal.c +++ b/util-linux/cal.c | |||
@@ -16,7 +16,8 @@ | |||
16 | //config: help | 16 | //config: help |
17 | //config: cal is used to display a monthly calendar. | 17 | //config: cal is used to display a monthly calendar. |
18 | 18 | ||
19 | //applet:IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP)) | 19 | //applet:IF_CAL(APPLET_NOEXEC(cal, cal, BB_DIR_USR_BIN, BB_SUID_DROP, cal)) |
20 | /* NOEXEC despite rare cases when it can be a "runner" (e.g. cal -n12000 takes you into years 30xx) */ | ||
20 | 21 | ||
21 | //kbuild:lib-$(CONFIG_CAL) += cal.o | 22 | //kbuild:lib-$(CONFIG_CAL) += cal.o |
22 | 23 | ||
diff --git a/util-linux/chrt.c b/util-linux/chrt.c index 2712ea3e3..45459d940 100644 --- a/util-linux/chrt.c +++ b/util-linux/chrt.c | |||
@@ -9,7 +9,7 @@ | |||
9 | //config: bool "chrt (4.4 kb)" | 9 | //config: bool "chrt (4.4 kb)" |
10 | //config: default y | 10 | //config: default y |
11 | //config: help | 11 | //config: help |
12 | //config: manipulate real-time attributes of a process. | 12 | //config: Manipulate real-time attributes of a process. |
13 | //config: This requires sched_{g,s}etparam support in your libc. | 13 | //config: This requires sched_{g,s}etparam support in your libc. |
14 | 14 | ||
15 | //applet:IF_CHRT(APPLET_NOEXEC(chrt, chrt, BB_DIR_USR_BIN, BB_SUID_DROP, chrt)) | 15 | //applet:IF_CHRT(APPLET_NOEXEC(chrt, chrt, BB_DIR_USR_BIN, BB_SUID_DROP, chrt)) |
@@ -17,13 +17,15 @@ | |||
17 | //kbuild:lib-$(CONFIG_CHRT) += chrt.o | 17 | //kbuild:lib-$(CONFIG_CHRT) += chrt.o |
18 | 18 | ||
19 | //usage:#define chrt_trivial_usage | 19 | //usage:#define chrt_trivial_usage |
20 | //usage: "[-prfom] [PRIO] [PID | PROG ARGS]" | 20 | //usage: "[-prfombi] [PRIO] [PID | PROG ARGS]" |
21 | //usage:#define chrt_full_usage "\n\n" | 21 | //usage:#define chrt_full_usage "\n\n" |
22 | //usage: "Change scheduling priority and class for a process\n" | 22 | //usage: "Change scheduling priority and class for a process\n" |
23 | //usage: "\n -p Operate on PID" | 23 | //usage: "\n -p Operate on PID" |
24 | //usage: "\n -r Set SCHED_RR class" | 24 | //usage: "\n -r Set SCHED_RR class" |
25 | //usage: "\n -f Set SCHED_FIFO class" | 25 | //usage: "\n -f Set SCHED_FIFO class" |
26 | //usage: "\n -o Set SCHED_OTHER class" | 26 | //usage: "\n -o Set SCHED_OTHER class" |
27 | //usage: "\n -b Set SCHED_BATCH class" | ||
28 | //usage: "\n -i Set SCHED_IDLE class" | ||
27 | //usage: "\n -m Show min/max priorities" | 29 | //usage: "\n -m Show min/max priorities" |
28 | //usage: | 30 | //usage: |
29 | //usage:#define chrt_example_usage | 31 | //usage:#define chrt_example_usage |
@@ -33,20 +35,22 @@ | |||
33 | 35 | ||
34 | #include <sched.h> | 36 | #include <sched.h> |
35 | #include "libbb.h" | 37 | #include "libbb.h" |
38 | #ifndef SCHED_IDLE | ||
39 | # define SCHED_IDLE 5 | ||
40 | #endif | ||
36 | 41 | ||
37 | static const struct { | 42 | static const struct { |
38 | int policy; | ||
39 | char name[sizeof("SCHED_OTHER")]; | 43 | char name[sizeof("SCHED_OTHER")]; |
40 | } policies[] = { | 44 | } policies[] = { |
41 | {SCHED_OTHER, "SCHED_OTHER"}, | 45 | { "SCHED_OTHER" }, /* 0:SCHED_OTHER */ |
42 | {SCHED_FIFO, "SCHED_FIFO"}, | 46 | { "SCHED_FIFO" }, /* 1:SCHED_FIFO */ |
43 | {SCHED_RR, "SCHED_RR"} | 47 | { "SCHED_RR" }, /* 2:SCHED_RR */ |
48 | { "SCHED_BATCH" }, /* 3:SCHED_BATCH */ | ||
49 | { "" }, /* 4:SCHED_ISO */ | ||
50 | { "SCHED_IDLE" }, /* 5:SCHED_IDLE */ | ||
51 | /* 6:SCHED_DEADLINE */ | ||
44 | }; | 52 | }; |
45 | 53 | ||
46 | //TODO: add | ||
47 | // -b, SCHED_BATCH | ||
48 | // -i, SCHED_IDLE | ||
49 | |||
50 | static void show_min_max(int pol) | 54 | static void show_min_max(int pol) |
51 | { | 55 | { |
52 | const char *fmt = "%s min/max priority\t: %u/%u\n"; | 56 | const char *fmt = "%s min/max priority\t: %u/%u\n"; |
@@ -64,6 +68,8 @@ static void show_min_max(int pol) | |||
64 | #define OPT_r (1<<2) | 68 | #define OPT_r (1<<2) |
65 | #define OPT_f (1<<3) | 69 | #define OPT_f (1<<3) |
66 | #define OPT_o (1<<4) | 70 | #define OPT_o (1<<4) |
71 | #define OPT_b (1<<5) | ||
72 | #define OPT_i (1<<6) | ||
67 | 73 | ||
68 | int chrt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 74 | int chrt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
69 | int chrt_main(int argc UNUSED_PARAM, char **argv) | 75 | int chrt_main(int argc UNUSED_PARAM, char **argv) |
@@ -76,20 +82,30 @@ int chrt_main(int argc UNUSED_PARAM, char **argv) | |||
76 | const char *current_new; | 82 | const char *current_new; |
77 | int policy = SCHED_RR; | 83 | int policy = SCHED_RR; |
78 | 84 | ||
79 | /* only one policy accepted */ | 85 | opt = getopt32(argv, "^" |
80 | opt = getopt32(argv, "^+" "mprfo" "\0" "r--fo:f--ro:o--rf"); | 86 | "+" "mprfobi" |
87 | "\0" | ||
88 | /* only one policy accepted: */ | ||
89 | "r--fobi:f--robi:o--rfbi:b--rfoi:i--rfob" | ||
90 | ); | ||
81 | if (opt & OPT_m) { /* print min/max and exit */ | 91 | if (opt & OPT_m) { /* print min/max and exit */ |
92 | show_min_max(SCHED_OTHER); | ||
82 | show_min_max(SCHED_FIFO); | 93 | show_min_max(SCHED_FIFO); |
83 | show_min_max(SCHED_RR); | 94 | show_min_max(SCHED_RR); |
84 | show_min_max(SCHED_OTHER); | 95 | show_min_max(SCHED_BATCH); |
96 | show_min_max(SCHED_IDLE); | ||
85 | fflush_stdout_and_exit(EXIT_SUCCESS); | 97 | fflush_stdout_and_exit(EXIT_SUCCESS); |
86 | } | 98 | } |
87 | if (opt & OPT_r) | 99 | //if (opt & OPT_r) |
88 | policy = SCHED_RR; | 100 | // policy = SCHED_RR; - default, already set |
89 | if (opt & OPT_f) | 101 | if (opt & OPT_f) |
90 | policy = SCHED_FIFO; | 102 | policy = SCHED_FIFO; |
91 | if (opt & OPT_o) | 103 | if (opt & OPT_o) |
92 | policy = SCHED_OTHER; | 104 | policy = SCHED_OTHER; |
105 | if (opt & OPT_b) | ||
106 | policy = SCHED_BATCH; | ||
107 | if (opt & OPT_i) | ||
108 | policy = SCHED_IDLE; | ||
93 | 109 | ||
94 | argv += optind; | 110 | argv += optind; |
95 | if (!argv[0]) | 111 | if (!argv[0]) |
@@ -131,12 +147,9 @@ int chrt_main(int argc UNUSED_PARAM, char **argv) | |||
131 | current_new += 8; | 147 | current_new += 8; |
132 | } | 148 | } |
133 | 149 | ||
134 | /* from the manpage of sched_getscheduler: | 150 | sp.sched_priority = xstrtou_range(priority, 0, |
135 | [...] sched_priority can have a value in the range 0 to 99. | 151 | sched_get_priority_min(policy), sched_get_priority_max(policy) |
136 | [...] SCHED_OTHER or SCHED_BATCH must be assigned static priority 0. | 152 | ); |
137 | [...] SCHED_FIFO or SCHED_RR can have static priority in 1..99 range. | ||
138 | */ | ||
139 | sp.sched_priority = xstrtou_range(priority, 0, policy != SCHED_OTHER ? 1 : 0, 99); | ||
140 | 153 | ||
141 | if (sched_setscheduler(pid, policy, &sp) < 0) | 154 | if (sched_setscheduler(pid, policy, &sp) < 0) |
142 | bb_perror_msg_and_die("can't %cet pid %d's policy", 's', (int)pid); | 155 | bb_perror_msg_and_die("can't %cet pid %d's policy", 's', (int)pid); |
diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c index 45d2aa6e7..cdb90627d 100644 --- a/util-linux/fdisk_gpt.c +++ b/util-linux/fdisk_gpt.c | |||
@@ -177,7 +177,7 @@ check_gpt_label(void) | |||
177 | 177 | ||
178 | init_unicode(); | 178 | init_unicode(); |
179 | if (!global_crc32_table) { | 179 | if (!global_crc32_table) { |
180 | global_crc32_table = crc32_filltable(NULL, 0); | 180 | global_crc32_new_table_le(); |
181 | } | 181 | } |
182 | 182 | ||
183 | crc = SWAP_LE32(gpt_hdr->hdr_crc32); | 183 | crc = SWAP_LE32(gpt_hdr->hdr_crc32); |
diff --git a/util-linux/renice.c b/util-linux/renice.c index 70c494b3d..46704591f 100644 --- a/util-linux/renice.c +++ b/util-linux/renice.c | |||
@@ -6,7 +6,6 @@ | |||
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | |||
10 | /* Notes: | 9 | /* Notes: |
11 | * Setting an absolute priority was obsoleted in SUSv2 and removed | 10 | * Setting an absolute priority was obsoleted in SUSv2 and removed |
12 | * in SUSv3. However, the common linux version of renice does | 11 | * in SUSv3. However, the common linux version of renice does |
@@ -42,10 +41,6 @@ | |||
42 | #include "libbb.h" | 41 | #include "libbb.h" |
43 | #include <sys/resource.h> | 42 | #include <sys/resource.h> |
44 | 43 | ||
45 | void BUG_bad_PRIO_PROCESS(void); | ||
46 | void BUG_bad_PRIO_PGRP(void); | ||
47 | void BUG_bad_PRIO_USER(void); | ||
48 | |||
49 | int renice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 44 | int renice_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
50 | int renice_main(int argc UNUSED_PARAM, char **argv) | 45 | int renice_main(int argc UNUSED_PARAM, char **argv) |
51 | { | 46 | { |
@@ -59,12 +54,9 @@ int renice_main(int argc UNUSED_PARAM, char **argv) | |||
59 | char *arg; | 54 | char *arg; |
60 | 55 | ||
61 | /* Yes, they are not #defines in glibc 2.4! #if won't work */ | 56 | /* Yes, they are not #defines in glibc 2.4! #if won't work */ |
62 | if (PRIO_PROCESS < CHAR_MIN || PRIO_PROCESS > CHAR_MAX) | 57 | BUILD_BUG_ON(PRIO_PROCESS < CHAR_MIN || PRIO_PROCESS > CHAR_MAX); |
63 | BUG_bad_PRIO_PROCESS(); | 58 | BUILD_BUG_ON(PRIO_PGRP < CHAR_MIN || PRIO_PGRP > CHAR_MAX); |
64 | if (PRIO_PGRP < CHAR_MIN || PRIO_PGRP > CHAR_MAX) | 59 | BUILD_BUG_ON(PRIO_USER < CHAR_MIN || PRIO_USER > CHAR_MAX); |
65 | BUG_bad_PRIO_PGRP(); | ||
66 | if (PRIO_USER < CHAR_MIN || PRIO_USER > CHAR_MAX) | ||
67 | BUG_bad_PRIO_USER(); | ||
68 | 60 | ||
69 | arg = *++argv; | 61 | arg = *++argv; |
70 | 62 | ||
@@ -102,6 +94,7 @@ int renice_main(int argc UNUSED_PARAM, char **argv) | |||
102 | /* Process an ID arg. */ | 94 | /* Process an ID arg. */ |
103 | if (which == PRIO_USER) { | 95 | if (which == PRIO_USER) { |
104 | struct passwd *p; | 96 | struct passwd *p; |
97 | /* NB: use of getpwnam makes it risky to be NOFORK, switch to getpwnam_r? */ | ||
105 | p = getpwnam(arg); | 98 | p = getpwnam(arg); |
106 | if (!p) { | 99 | if (!p) { |
107 | bb_error_msg("unknown user %s", arg); | 100 | bb_error_msg("unknown user %s", arg); |
diff --git a/util-linux/umount.c b/util-linux/umount.c index a6405dfcc..b45cd8a6b 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c | |||
@@ -81,8 +81,8 @@ static struct mntent *getmntent_r(FILE* stream, struct mntent* result, | |||
81 | } | 81 | } |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | /* ignored: -v -t -i */ | 84 | /* ignored: -c -v -t -i */ |
85 | #define OPTION_STRING "fldnra" "vt:i" | 85 | #define OPTION_STRING "fldnra" "cvt:i" |
86 | #define OPT_FORCE (1 << 0) // Same as MNT_FORCE | 86 | #define OPT_FORCE (1 << 0) // Same as MNT_FORCE |
87 | #define OPT_LAZY (1 << 1) // Same as MNT_DETACH | 87 | #define OPT_LAZY (1 << 1) // Same as MNT_DETACH |
88 | #define OPT_FREELOOP (1 << 2) | 88 | #define OPT_FREELOOP (1 << 2) |
diff --git a/util-linux/volume_id/lfs.c b/util-linux/volume_id/lfs.c new file mode 100644 index 000000000..1a2a2987f --- /dev/null +++ b/util-linux/volume_id/lfs.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /* | ||
2 | * volume_id - reads filesystem label and uuid | ||
3 | * | ||
4 | * Copyright (C) 2018 Sven-Göran Bergh <sgb@systemaxion.se> | ||
5 | * | ||
6 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
7 | */ | ||
8 | //config:config FEATURE_VOLUMEID_LFS | ||
9 | //config: bool "LittleFS filesystem" | ||
10 | //config: default y | ||
11 | //config: depends on VOLUMEID && FEATURE_BLKID_TYPE | ||
12 | //config: help | ||
13 | //config: LittleFS is a small fail-safe filesystem designed for embedded | ||
14 | //config: systems. It has strong copy-on-write guarantees and storage on disk | ||
15 | //config: is always kept in a valid state. It also provides a form of dynamic | ||
16 | //config: wear levelling for systems that can not fit a full flash translation | ||
17 | //config: layer. | ||
18 | |||
19 | //kbuild:lib-$(CONFIG_FEATURE_VOLUMEID_LFS) += lfs.o | ||
20 | |||
21 | #include "volume_id_internal.h" | ||
22 | |||
23 | #define LFS_SB1_OFFSET 0x10 | ||
24 | #define LFS_MAGIC_NAME "littlefs" | ||
25 | #define LFS_MAGIC_LEN 8 | ||
26 | |||
27 | // The superblock is stored in the first metadata pair, i.e the first two blocks. | ||
28 | struct lfs_super_block { // A block in a metadata pair | ||
29 | // /* 0x00 */ uint32_t rev_count; // Revision count | ||
30 | // /* 0x04 */ uint32_t dir_size; // Directory size | ||
31 | // /* 0x08 */ uint64_t tail_ptr; // Tail pointer | ||
32 | /* 0x10 */ uint8_t entry_type; // Entry type | ||
33 | /* 0x11 */ uint8_t entry_len; // Entry length | ||
34 | /* 0x12 */ uint8_t att_len; // Attribute length | ||
35 | /* 0x13 */ uint8_t name_len; // Name length | ||
36 | /* 0x14 */ uint64_t root_dir; // Root directory | ||
37 | /* 0x1C */ uint32_t block_size; // Block size | ||
38 | /* 0x20 */ uint32_t block_count; // Block count | ||
39 | /* 0x24 */ uint16_t ver_major; // Version major | ||
40 | /* 0x26 */ uint16_t ver_minor; // Version minor | ||
41 | /* 0x28 */ uint8_t magic[LFS_MAGIC_LEN]; // Magic string "littlefs" | ||
42 | // /* 0x30 */ uint32_t crc; // CRC-32 checksum | ||
43 | } PACKED; | ||
44 | |||
45 | int FAST_FUNC volume_id_probe_lfs(struct volume_id *id /*,uint64_t off*/) | ||
46 | { | ||
47 | struct lfs_super_block *sb; | ||
48 | |||
49 | // Go for primary super block (ignore second sb) | ||
50 | dbg("lfs: probing at offset 0x%x", LFS_SB1_OFFSET); | ||
51 | sb = volume_id_get_buffer(id, LFS_SB1_OFFSET, sizeof(*sb)); | ||
52 | |||
53 | if (!sb) | ||
54 | return -1; | ||
55 | |||
56 | if (memcmp(sb->magic, LFS_MAGIC_NAME, LFS_MAGIC_LEN) != 0) | ||
57 | return -1; | ||
58 | |||
59 | IF_FEATURE_BLKID_TYPE(id->type = LFS_MAGIC_NAME); | ||
60 | |||
61 | return 0; | ||
62 | } | ||
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c index 85315ced6..c3f07a741 100644 --- a/util-linux/volume_id/volume_id.c +++ b/util-linux/volume_id/volume_id.c | |||
@@ -97,6 +97,9 @@ static const probe_fptr fs1[] = { | |||
97 | #if ENABLE_FEATURE_VOLUMEID_EXFAT | 97 | #if ENABLE_FEATURE_VOLUMEID_EXFAT |
98 | volume_id_probe_exfat, | 98 | volume_id_probe_exfat, |
99 | #endif | 99 | #endif |
100 | #if ENABLE_FEATURE_VOLUMEID_LFS | ||
101 | volume_id_probe_lfs, | ||
102 | #endif | ||
100 | #if ENABLE_FEATURE_VOLUMEID_MAC | 103 | #if ENABLE_FEATURE_VOLUMEID_MAC |
101 | volume_id_probe_mac_partition_map, | 104 | volume_id_probe_mac_partition_map, |
102 | #endif | 105 | #endif |
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h index 0eaea9b34..ada18339d 100644 --- a/util-linux/volume_id/volume_id_internal.h +++ b/util-linux/volume_id/volume_id_internal.h | |||
@@ -187,6 +187,8 @@ int FAST_FUNC volume_id_probe_iso9660(struct volume_id *id /*,uint64_t off*/); | |||
187 | 187 | ||
188 | int FAST_FUNC volume_id_probe_jfs(struct volume_id *id /*,uint64_t off*/); | 188 | int FAST_FUNC volume_id_probe_jfs(struct volume_id *id /*,uint64_t off*/); |
189 | 189 | ||
190 | int FAST_FUNC volume_id_probe_lfs(struct volume_id *id /*,uint64_t off*/); | ||
191 | |||
190 | int FAST_FUNC volume_id_probe_linux_swap(struct volume_id *id /*,uint64_t off*/); | 192 | int FAST_FUNC volume_id_probe_linux_swap(struct volume_id *id /*,uint64_t off*/); |
191 | 193 | ||
192 | int FAST_FUNC volume_id_probe_luks(struct volume_id *id /*,uint64_t off*/); | 194 | int FAST_FUNC volume_id_probe_luks(struct volume_id *id /*,uint64_t off*/); |