Skip to content

khitiara changes diff #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
});
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
},
}
}
Expand Down Expand Up @@ -734,6 +732,8 @@ pub const mbr = struct {
empty = 0x00,

fat12 = 0x01,
fat16_small = 0x04,
fat16 = 0x06,
ntfs = 0x07,

fat32_chs = 0x0B,
Expand Down
5 changes: 2 additions & 3 deletions build.zig.zon
Original file line number Diff line number Diff line change
@@ -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"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is obviously not meant to be upstreamed

},
},
.paths = .{
Expand Down
10 changes: 8 additions & 2 deletions src/shared.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Comment on lines -99 to +105

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was just for trying to trace an error i had, not necessary or worth forwarding

defer file.close();

try addFile(file, dst);
Expand Down Expand Up @@ -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);
Expand Down