Updated performance values in README.

Added ability to ignore xattrs & permissions.
Ignore setting xattr errors due to an unknown issues.
This commit is contained in:
Caleb J. Gardner
2026-03-04 13:28:29 -06:00
parent edfe919c1b
commit a4e23a840d
3 changed files with 25 additions and 13 deletions
+12
View File
@@ -14,6 +14,8 @@ const help_mgs =
\\ -d <location> Extract to the given location instead of "squashfs-root"
\\
\\ -o <offset> 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 <threads> 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);
+4 -5
View File
@@ -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;
}
}
}