Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/util-linux/volume_id/util.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/util-linux/volume_id/util.c
r2725 r3232 32 32 else 33 33 c = (buf[i] << 8) | buf[i+1]; 34 if (c == 0) { 35 str[j] = '\0'; 34 if (c == 0) 36 35 break; 37 } else if (c < 0x80) { 38 if (j+1 >= len) 39 break; 40 str[j++] = (uint8_t) c; 41 } else if (c < 0x800) { 36 if (j+1 >= len) 37 break; 38 if (c < 0x80) { 39 /* 0xxxxxxx */ 40 } else { 41 uint8_t topbits = 0xc0; 42 42 if (j+2 >= len) 43 43 break; 44 str[j++] = (uint8_t) (0xc0 | (c >> 6)); 45 str[j++] = (uint8_t) (0x80 | (c & 0x3f)); 46 } else { 47 if (j+3 >= len) 48 break; 49 str[j++] = (uint8_t) (0xe0 | (c >> 12)); 50 str[j++] = (uint8_t) (0x80 | ((c >> 6) & 0x3f)); 51 str[j++] = (uint8_t) (0x80 | (c & 0x3f)); 44 if (c < 0x800) { 45 /* 110yyyxx 10xxxxxx */ 46 } else { 47 if (j+3 >= len) 48 break; 49 /* 1110yyyy 10yyyyxx 10xxxxxx */ 50 str[j++] = (uint8_t) (0xe0 | (c >> 12)); 51 topbits = 0x80; 52 } 53 str[j++] = (uint8_t) (topbits | ((c >> 6) & 0x3f)); 54 c = 0x80 | (c & 0x3f); 52 55 } 56 str[j++] = (uint8_t) c; 53 57 } 54 58 str[j] = '\0'; … … 126 130 void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count) 127 131 { 128 132 volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count); 129 133 } 130 134 … … 132 136 { 133 137 unsigned i; 134 unsigned count = 0; 135 136 switch (format) { 137 case UUID_DOS: 138 count = 4; 139 break; 140 case UUID_NTFS: 141 case UUID_HFS: 142 count = 8; 143 break; 144 case UUID_DCE: 145 count = 16; 146 break; 147 case UUID_DCE_STRING: 148 /* 36 is ok, id->uuid has one extra byte for NUL */ 149 count = VOLUME_ID_UUID_SIZE; 150 break; 151 } 138 unsigned count = (format == UUID_DCE_STRING ? VOLUME_ID_UUID_SIZE : 4 << format); 139 152 140 // memcpy(id->uuid_raw, buf, count); 153 141 // id->uuid_raw_len = count; … … 169 157 buf[7], buf[6], buf[5], buf[4], 170 158 buf[3], buf[2], buf[1], buf[0]); 171 break;172 case UUID_HFS:173 sprintf(id->uuid, "%02X%02X%02X%02X%02X%02X%02X%02X",174 buf[0], buf[1], buf[2], buf[3],175 buf[4], buf[5], buf[6], buf[7]);176 159 break; 177 160 case UUID_DCE:
Note:
See TracChangeset
for help on using the changeset viewer.