Repository navigation
Commit 9822f73
lxutil: hard-link to one-character names on Windows
On a Windows host, LxVolume::link and LxVolume::link_stat failed with
EOVERFLOW, and created no link, when the new name was one UTF-16 unit
long, such as `x`, although longer names worked (microsoft/nvx#2136).
A guest's `ln file x` on a virtio-fs share of a Windows directory thus
failed, and so would one on a Plan 9 share, which links through the
same LxVolume::link.
create_link passes NtSetInformationFile a FILE_LINK_INFORMATION built
from a header that mirrors the structure up to FileName, 20 bytes with
an alignment of 1, followed by the name. NtSetInformationFile refuses a
buffer shorter than sizeof(FILE_LINK_INFORMATION), which counts the
first FileName unit and the trailing padding, 24 bytes on 64-bit
Windows, with STATUS_INFO_LENGTH_MISMATCH, which lxutil maps to
EOVERFLOW. A name of one unit made a buffer of 22 bytes. rename does
not fail this way: its header starts with the 4-byte union of
FILE_RENAME_INFORMATION, so its buffer rounds up to 24 bytes.
create_link now pads the name with NULs until the buffer is as long as
the structure, as pal's hard_link_relative already sizes its own.
FileNameLength still counts only the name, so the link gets exactly
that name.
link_to_a_one_character_name links a file to `a` through link and to
`b` through link_stat, and expects both names to reach the file, with
link counts of 2 and 3. Without the fix, its first link fails with
EOVERFLOW on Windows 11 Enterprise (build 26300, NTFS); with it, the
test passes there, as do the other tests of the lxutil and virtiofs
packages. A one-off test, not committed, of the issue's reproduction,
a FUSE_LINK through VirtioFs of a file to `xy` and then to `x`, with
the standard and the microVM profile, got EOVERFLOW for `x`, and left
no host file, at feature/microvm/dev 1633b37, and a link count of 3
with the fix.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 5af753b commit 9822f73
2 files changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2398 | 2398 | | |
2399 | 2399 | | |
2400 | 2400 | | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
2401 | 2420 | | |
2402 | 2421 | | |
2403 | 2422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1202 | 1202 | | |
1203 | 1203 | | |
1204 | 1204 | | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
1205 | 1214 | | |
1206 | 1215 | | |
1207 | 1216 | | |
| |||
0 commit comments