|
From: | Michael Tokarev |
Subject: | Re: [PATCH] vvfat: refresh writing long filename |
Date: | Sat, 18 Jan 2025 23:37:35 +0300 |
User-agent: | Mozilla Thunderbird |
18.01.2025 23:32, Volker Rümelin wrote:
+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; + }Hi Michael, this is not right. It's necessary to initialize the remaining elements of the name arrays. The rules are: If the file name length in characters is a multiple of 13 you are done. Otherwise the remaining unused LFN direntry name array elements have to be filled with one 0x0000 (a 16 bit 0) and the rest with 0xffff.
I wonder how it worked for me. I tested it with linux and windows guests. Hmm. Well, it's rather trivial to fix this. Lemme do just that..
+ lptr += write_lfn_part(entry->name1c, sizeof(entry->name1c), lptr, lend);I would use ARRAY_SIZE() instead of sizeof(). ARRAY_SIZE() is the number of elements an array can hold. You then don't have to remember the size of an array element.
sizeof() works fine here :) /mjt
[Prev in Thread] | Current Thread | [Next in Thread] |