diff --git a/build.zig b/build.zig index d2077be..be6d096 100644 --- a/build.zig +++ b/build.zig @@ -129,7 +129,7 @@ pub fn build(b: *std.Build) void { const mkfs_fat = b.addExecutable(.{ .name = "mkfs.fat", - .target = b.host, + .target = b.resolveTargetQuery(.{}), .optimize = .ReleaseSafe, .root_source_file = b.path("src/mkfs.fat.zig"), }); @@ -416,7 +416,7 @@ pub const InitializeDiskStep = struct { var buffer: [64]u8 = undefined; context.appendSliceAssumeCapacity(std.fmt.bufPrint(&buffer, "[{}]", .{part_id}) catch unreachable); - try writeDiskImage(b, asking, disk, base + auto_offset, part.size, part.data, context); + try writeDiskImage(b, asking, disk, part.offset orelse base + auto_offset, part.size, part.data, context); auto_offset += part.size; } @@ -524,9 +524,8 @@ pub const InitializeDiskStep = struct { } } - fn make(step: *std.Build.Step, progress: std.Progress.Node) !void { + fn make(step: *std.Build.Step, _: std.Build.Step.MakeOptions) !void { const b = step.owner; - _ = progress; const ids: *InitializeDiskStep = @fieldParentPtr("step", step); @@ -629,11 +628,10 @@ pub const Content = union(enum) { dir.* = try allocator.dupe(u8, dir.*); }, .copy_dir, .copy_file => |*cp| { - const cp_new = .{ + cp.* = .{ .destination = try allocator.dupe(u8, cp.destination), .source = cp.source.dupe(b), }; - cp.* = cp_new; }, } } @@ -734,6 +732,8 @@ pub const mbr = struct { empty = 0x00, fat12 = 0x01, + fat16_small = 0x04, + fat16 = 0x06, ntfs = 0x07, fat32_chs = 0x0B, diff --git a/build.zig.zon b/build.zig.zon index 7dc6680..2055aba 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,10 +1,9 @@ .{ - .name = "disk-image-step", + .name = "disk_image_step", .version = "0.1.0", .dependencies = .{ .zfat = .{ - .url = "https://github.com/ZigEmbeddedGroup/zfat/archive/68dbbe19258b174fe4f374a91b4cc939019d9fe7.tar.gz", - .hash = "1220963601b9bc8dacc422d098368567e5c7b84d21f9ae73067fe3eb9c566aea02fd", + .path = "../../libs/zfat" }, }, .paths = .{ diff --git a/src/shared.zig b/src/shared.zig index 990aff8..c5dfa31 100644 --- a/src/shared.zig +++ b/src/shared.zig @@ -96,7 +96,13 @@ pub fn App(comptime Context: type) type { // std.log.info("file(\"{}\", \"{}\")", .{ std.zig.fmtEscapes(src), std.zig.fmtEscapes(dst) }); - var file = try std.fs.cwd().openFile(src, .{}); + var file = std.fs.cwd().openFile(src, .{}) catch |err| switch (err) { + error.FileNotFound => { + std.log.err("file not found: {s}", .{src}); + return err; + }, + else => return err, + }; defer file.close(); try addFile(file, dst); @@ -180,7 +186,7 @@ pub fn App(comptime Context: type) type { continue; } else if (std.mem.eql(u8, part, "..")) { // "cd up" is basically just removing the last pushed part - _ = list.popOrNull(); + _ = list.pop(); } else { // this is an actual "descend" try list.append(part);