diff --git a/README.md b/README.md index 7000996..7ec974f 100644 --- a/README.md +++ b/README.md @@ -37,17 +37,18 @@ Most features are present except for the following: This is some basic observation's I've made about this library's performance when compared to `unsquashfs`. Unless otherwise stated, most observations were made when extracting my test archive (which is fairly small and uses zstd compression) and with `--release=fast`. -* Under ideal circumstances, my library is ~70% slower (.11s vs .18s) -* Mutli-threading on small archives significantly increases extraction times (when using C libraries) (.18s vs .57s). This should theoretically reverse on larger archives with many inodes, but I haven't tested that yet. -* Using Zig libraries *significantly* increases decompression time by ~600% under ideal circumstances. +* Under ideal circumstances, my library is ~60% slower (.12s vs .19s). +* Using Zig decompression libraries *significantly* increases decompression time by ~600%. Under ideal circumstances. +* Performance improvements/regressions will be common. I'm still learning Zig. Example Times: -* *unsquashfs*: .11s -* *C-libs, single-threaded*: .18s -* *C-libs, multi-threaded*: .57s -* *Zig-libs, single-threaded*: 5.87s -* *Zig-libs, multi-threaded*: 1.10s +* *unsquashfs, multi-threaded*: .12s +* *unsquashfs, single-threaded*: .13s +* *C-libs, single-threaded*: .56s +* *C-libs, multi-threaded*: .19s +* *Zig-libs, single-threaded*: 5.78s +* *Zig-libs, multi-threaded*: 1.08s ## Build considerations diff --git a/src/bin/unsquashfs.zig b/src/bin/unsquashfs.zig index 69b6789..1db474f 100644 --- a/src/bin/unsquashfs.zig +++ b/src/bin/unsquashfs.zig @@ -14,6 +14,8 @@ const help_mgs = \\ -d Extract to the given location instead of "squashfs-root" \\ \\ -o Start reading the archive at the given offset. + \\ -dx Don't set xattr values + \\ -dp Don't set permissions (includes setting uid & gid owner) \\ \\ -p Specify how many threads to use. If no present or zero, the system's logical cores count is used. \\ -v Verbose @@ -30,6 +32,8 @@ var extLoc: []const u8 = "squashfs-root"; var offset: u64 = 0; var threads: u32 = 0; var verbose: bool = false; +var ignore_xattrs: bool = false; +var ignore_permissions: bool = false; pub fn main() !void { const alloc = std.heap.smp_allocator; @@ -50,6 +54,8 @@ pub fn main() !void { .threads = if (threads == 0) try std.Thread.getCpuCount() else threads, .verbose = verbose, .verbose_writer = if (verbose) &out.interface else null, + .ignore_xattr = ignore_xattrs, + .ignore_permissions = ignore_permissions, }; try arc.extract(alloc, extLoc, options); //TODO: Handle error gracefully. } @@ -92,6 +98,12 @@ fn handleArgs(alloc: std.mem.Allocator, out: *Writer) !void { } else if (std.mem.eql(u8, arg, "-v")) { verbose = true; continue; + } else if (std.mem.eql(u8, arg, "-dx")) { + ignore_xattrs = true; + continue; + } else if (std.mem.eql(u8, arg, "-dp")) { + ignore_permissions = true; + continue; } else if (std.mem.eql(u8, arg, "--version")) { try out.print("zig-unsquashfs v", .{}); try config.version.format(out); diff --git a/src/inode.zig b/src/inode.zig index 9246b6b..de1fe9a 100644 --- a/src/inode.zig +++ b/src/inode.zig @@ -183,15 +183,14 @@ pub fn setMetadata(self: Inode, alloc: std.mem.Allocator, archive: *Archive, fil const xattrs = try archive.xattr_table.get(alloc, idx); defer alloc.free(xattrs); for (xattrs) |kv| { - defer { - alloc.free(kv.key); - alloc.free(kv.value); - } const res = std.os.linux.fsetxattr(fil.handle, @ptrCast(kv.key), @ptrCast(kv.value), kv.value.len, 0); + alloc.free(kv.key); + alloc.free(kv.value); if (res != 0) { if (options.verbose) options.verbose_writer.?.print("fsetxattr has result of: {}\n", .{res}) catch {}; - return error.SetXattr; + //TODO: Currently this seems a bit flakey, so we just ignore the result... for now. + // return error.SetXattr; } } }