diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-19 11:00:52 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-06-19 11:00:52 +0200 |
commit | b96159d6631065512c775f560b1bd9d1f6ffd1ec (patch) | |
tree | 47c8bc8a17cf127c8b7b027e92893aa5fbe3a223 | |
parent | e1e2273076b43a4535a139de21b9ead7835f7c79 (diff) | |
download | busybox-w32-b96159d6631065512c775f560b1bd9d1f6ffd1ec.tar.gz busybox-w32-b96159d6631065512c775f560b1bd9d1f6ffd1ec.tar.bz2 busybox-w32-b96159d6631065512c775f560b1bd9d1f6ffd1ec.zip |
mkswap: accidentally committed wrong patch. fix it up
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/mkswap.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index c4e30fd92..5d1f6f05d 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c | |||
@@ -53,10 +53,6 @@ static void mkswap_selinux_setcontext(int fd, const char *path) | |||
53 | #if ENABLE_DESKTOP | 53 | #if ENABLE_DESKTOP |
54 | static void mkswap_generate_uuid(uint8_t *buf) | 54 | static void mkswap_generate_uuid(uint8_t *buf) |
55 | { | 55 | { |
56 | pid_t pid; | ||
57 | unsigned i; | ||
58 | char uuid_string[32]; | ||
59 | |||
60 | /* http://www.ietf.org/rfc/rfc4122.txt | 56 | /* http://www.ietf.org/rfc/rfc4122.txt |
61 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 | 57 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
62 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 58 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
@@ -64,7 +60,7 @@ static void mkswap_generate_uuid(uint8_t *buf) | |||
64 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 60 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
65 | * | time_mid | time_hi_and_version | | 61 | * | time_mid | time_hi_and_version | |
66 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 62 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
67 | * |clk_seq__and_variant | node (0-1) | | 63 | * |clk_seq_and_variant | node (0-1) | |
68 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 64 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
69 | * | node (2-5) | | 65 | * | node (2-5) | |
70 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | 66 | * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
@@ -73,11 +69,11 @@ static void mkswap_generate_uuid(uint8_t *buf) | |||
73 | * uint16_t time_mid (big endian) | 69 | * uint16_t time_mid (big endian) |
74 | * uint16_t time_hi_and_version (big endian) | 70 | * uint16_t time_hi_and_version (big endian) |
75 | * version is a 4-bit field: | 71 | * version is a 4-bit field: |
76 | * 1 Time-based version | 72 | * 1 Time-based |
77 | * 2 DCE Security version, with embedded POSIX UIDs | 73 | * 2 DCE Security, with embedded POSIX UIDs |
78 | * 3 Name-based version (MD5) | 74 | * 3 Name-based (MD5) |
79 | * 4 Randomly generated version | 75 | * 4 Randomly generated |
80 | * 5 Name-based version (SHA-1) | 76 | * 5 Name-based (SHA-1) |
81 | * uint16_t clk_seq_and_variant (big endian) | 77 | * uint16_t clk_seq_and_variant (big endian) |
82 | * variant is a 3-bit field: | 78 | * variant is a 3-bit field: |
83 | * 0xx Reserved, NCS backward compatibility | 79 | * 0xx Reserved, NCS backward compatibility |
@@ -90,6 +86,9 @@ static void mkswap_generate_uuid(uint8_t *buf) | |||
90 | * time_hi_and_version & 0x0fff | 0x4000 | 86 | * time_hi_and_version & 0x0fff | 0x4000 |
91 | * clk_seq_and_variant & 0x3fff | 0x8000 | 87 | * clk_seq_and_variant & 0x3fff | 0x8000 |
92 | */ | 88 | */ |
89 | pid_t pid; | ||
90 | int i; | ||
91 | char uuid_string[32]; | ||
93 | 92 | ||
94 | i = open("/dev/urandom", O_RDONLY); | 93 | i = open("/dev/urandom", O_RDONLY); |
95 | if (i >= 0) { | 94 | if (i >= 0) { |
@@ -110,8 +109,10 @@ static void mkswap_generate_uuid(uint8_t *buf) | |||
110 | pid = 0; | 109 | pid = 0; |
111 | } | 110 | } |
112 | 111 | ||
113 | buf[4 + 2 ] = (buf[4 + 2 ] & 0x0f) | 0x40; /* time_hi_and_version */ | 112 | /* version = 4 */ |
114 | buf[4 + 2 + 2] = (buf[4 + 2 + 2] & 0x3f) | 0x80; /* clk_seq_and_variant */ | 113 | buf[4 + 2 ] = (buf[4 + 2 ] & 0x0f) | 0x40; |
114 | /* variant = 10x */ | ||
115 | buf[4 + 2 + 2] = (buf[4 + 2 + 2] & 0x3f) | 0x80; | ||
115 | 116 | ||
116 | bin2hex(uuid_string, (void*) buf, 16); | 117 | bin2hex(uuid_string, (void*) buf, 16); |
117 | /* f.e. UUID=dfd9c173-be52-4d27-99a5-c34c6c2ff55f */ | 118 | /* f.e. UUID=dfd9c173-be52-4d27-99a5-c34c6c2ff55f */ |