Skip to content

Commit 2f82d23

Browse files
committed
Debug Windows CI
1 parent 1bf7486 commit 2f82d23

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

lib/std/os.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,6 +4063,12 @@ pub fn realpathZ(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
40634063
pub fn realpathW(pathname: []const u16, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
40644064
const w = windows;
40654065

4066+
{
4067+
var buf: [1024]u8 = undefined;
4068+
const len = std.unicode.utf16leToUtf8(buf[0..], pathname) catch unreachable;
4069+
std.debug.print("realpathW with pathname = {}\n", .{buf[0..len]});
4070+
}
4071+
40664072
const dir = std.fs.cwd().fd;
40674073
const access_mask = w.GENERIC_READ | w.SYNCHRONIZE;
40684074
const share_access = w.FILE_SHARE_READ;
@@ -4098,6 +4104,11 @@ pub fn realpathW(pathname: []const u16, out_buffer: *[MAX_PATH_BYTES]u8) RealPat
40984104

40994105
// Trust that Windows gives us valid UTF-16LE.
41004106
const end_index = std.unicode.utf16leToUtf8(out_buffer, wide_slice) catch unreachable;
4107+
4108+
{
4109+
std.debug.print("realpathW real = {}\n", .{out_buffer[0..end_index]});
4110+
}
4111+
41014112
return out_buffer[0..end_index];
41024113
}
41034114

lib/std/os/windows.zig

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
128128
.OBJECT_NAME_COLLISION => return error.PathAlreadyExists,
129129
.FILE_IS_A_DIRECTORY => return error.IsDir,
130130
.NOT_A_DIRECTORY => return error.NotDir,
131-
else => return unexpectedStatus(rc),
131+
else => {
132+
std.debug.print("OpenFile = {}\n", .{rc});
133+
return unexpectedStatus(rc);
134+
},
132135
}
133136
}
134137
}
@@ -212,7 +215,10 @@ pub fn DeviceIoControl(
212215
switch (rc) {
213216
.SUCCESS => {},
214217
.INVALID_PARAMETER => unreachable,
215-
else => return unexpectedStatus(rc),
218+
else => {
219+
std.debug.print("DeviceIoControl = {}\n", .{rc});
220+
return unexpectedStatus(rc);
221+
},
216222
}
217223
}
218224

@@ -930,7 +936,10 @@ pub fn GetFinalPathNameByHandle(
930936
switch (rc) {
931937
.SUCCESS => {},
932938
.INVALID_PARAMETER => unreachable,
933-
else => return unexpectedStatus(rc),
939+
else => {
940+
std.debug.print("FileNormalizedNameInformation = {}\n", .{rc});
941+
return unexpectedStatus(rc);
942+
},
934943
}
935944

936945
// Get NT volume name.
@@ -939,7 +948,10 @@ pub fn GetFinalPathNameByHandle(
939948
switch (rc) {
940949
.SUCCESS => {},
941950
.INVALID_PARAMETER => unreachable,
942-
else => return unexpectedStatus(rc),
951+
else => {
952+
std.debug.print("FileVolumeNameInformation = {}\n", .{rc});
953+
return unexpectedStatus(rc);
954+
},
943955
}
944956

945957
const file_name = @ptrCast(*const FILE_NAME_INFORMATION, @alignCast(@alignOf(FILE_NAME_INFORMATION), &path_buffer[0]));
@@ -986,6 +998,10 @@ pub fn GetFinalPathNameByHandle(
986998
error.PipeBusy => unreachable,
987999
error.PathAlreadyExists => unreachable,
9881000
error.WouldBlock => unreachable,
1001+
error.Unexpected => {
1002+
std.debug.print("when opening \\MountPointManager\n", .{});
1003+
return error.Unexpected;
1004+
},
9891005
else => |e| return e,
9901006
};
9911007
defer CloseHandle(mgmt_handle);
@@ -1002,6 +1018,10 @@ pub fn GetFinalPathNameByHandle(
10021018
output_buf[0..],
10031019
);
10041020
const mount_points_struct = @ptrCast(*const MOUNTMGR_MOUNT_POINTS, @alignCast(@alignOf(MOUNTMGR_MOUNT_POINTS), &output_buf[0]));
1021+
{
1022+
std.debug.print("input_buf = {}\n", .{input_buf});
1023+
std.debug.print("output_buf = {}\n", .{output_buf});
1024+
}
10051025

10061026
const mount_points = @ptrCast(
10071027
[*]const MOUNTMGR_MOUNT_POINT,
@@ -1014,6 +1034,11 @@ pub fn GetFinalPathNameByHandle(
10141034
[*]const u16,
10151035
@alignCast(@alignOf(u16), &output_buf[mount_point.SymbolicLinkNameOffset]),
10161036
)[0 .. mount_point.SymbolicLinkNameLength / 2];
1037+
{
1038+
var buf: [1024]u8 = undefined;
1039+
const len = std.unicode.utf16leToUtf8(buf[0..], symlink) catch unreachable;
1040+
std.debug.print("symlink = {}\n", .{buf[0..len]});
1041+
}
10171042

10181043
// Look for `\DosDevices\` prefix. We don't really care if there are more than one symlinks
10191044
// with traditional DOS drive letters, so pick the first one available.
@@ -1022,7 +1047,12 @@ pub fn GetFinalPathNameByHandle(
10221047
if (std.mem.indexOf(u16, symlink, prefix)) |idx| {
10231048
if (idx != 0) continue;
10241049

1025-
const drive_letter = std.mem.trimLeft(u16, symlink, prefix);
1050+
const drive_letter = symlink[prefix.len..];
1051+
{
1052+
var buf: [1024]u8 = undefined;
1053+
const len = std.unicode.utf16leToUtf8(buf[0..], drive_letter) catch unreachable;
1054+
std.debug.print("drive_letter = {}\n", .{buf[0..len]});
1055+
}
10261056

10271057
if (out_buffer.len < drive_letter.len + file_name_u16.len) return error.NameTooLong;
10281058

0 commit comments

Comments
 (0)