18.01.2025 23:54, BALATON Zoltan wrote:
+typedef struct lfn_direntry_t { + uint8_t sequence; + uint8_t name01[10]; + uint8_t attributes; + uint8_t direntry_type; + uint8_t sfn_checksum; + uint8_t name0e[12]; + uint16_t begin; + uint8_t name1c[4]; +} QEMU_PACKED lfn_direntry_t;
+static unsigned write_lfn_part(uint8_t *dest, unsigned dsize, + const gunichar2 *lptr, const gunichar2 *lend) +{ + unsigned i; + for(i = 0; i < dsize / 2 && lptr + i < lend; ++i) { + dest[i / 2 + 0] = lptr[i] & 0xff; + dest[i / 2 + 1] = lptr[i] >> 8;Why not uint16_t and maybe cpu_to_le (or whatever that's called) if needed? May be simpler than handling it byte by byte.
The dest array is unaligned - this is, eg, name01 in the above struct. Will it work to use entry->name01[i] = cpu_to_le16(lptr[i]) here, provided lfn_direntry_t=>name is declared as uint16_t name[5] ? I haven't done programming for quite a while... ;) /mjt
