diff --git a/.github/release-nest-v3 b/.github/release-nest-v3 index d8263ee..56a6051 100644 --- a/.github/release-nest-v3 +++ b/.github/release-nest-v3 @@ -1 +1 @@ -2 \ No newline at end of file +1 \ No newline at end of file diff --git a/pikafetch/debian/changelog b/pikafetch/debian/changelog index 85157f3..7eae56e 100644 --- a/pikafetch/debian/changelog +++ b/pikafetch/debian/changelog @@ -1,4 +1,4 @@ -pikafetch (0.1.0-101pika7) pika; urgency=medium +pikafetch (0.1.0-101pika8) pika; urgency=medium * Initial release. diff --git a/pikafetch/src/system/hardware/disk.zig b/pikafetch/src/system/hardware/disk.zig index b4a443a..1f63534 100644 --- a/pikafetch/src/system/hardware/disk.zig +++ b/pikafetch/src/system/hardware/disk.zig @@ -1,55 +1,27 @@ const std = @import("std"); const os = std.os; const c = @cImport({ - @cInclude("sys/statvfs.h"); + @cInclude("sys/statfs.h"); }); pub const DiskInfo = struct { total: u64, used: u64, - fs_type: []const u8, allocator: std.mem.Allocator, - - pub fn deinit(self: *const DiskInfo) void { - self.allocator.free(self.fs_type); - } }; pub fn getDiskInfo(allocator: std.mem.Allocator, mount_point: []const u8) !DiskInfo { - var stats: c.struct_statvfs = undefined; - const rc = c.statvfs(mount_point.ptr, &stats); + var stats: c.struct_statfs = undefined; + const rc = c.statfs(mount_point.ptr, &stats); if (rc != 0) return error.StatFailed; - const total = stats.f_blocks * stats.f_frsize; - const free = stats.f_bfree * stats.f_frsize; + const total = @as(u64, @intCast(stats.f_blocks)) * @as(u64, @intCast(stats.f_bsize)); + const free = @as(u64, @intCast(stats.f_bfree)) * @as(u64, @intCast(stats.f_bsize)); const used = total - free; - // Get filesystem type - const mtab = try std.fs.openFileAbsolute("/proc/mounts", .{}); - defer mtab.close(); - - var buffer: [4096]u8 = undefined; - const bytes = try mtab.readAll(&buffer); - const content = buffer[0..bytes]; - - var fs_type: []const u8 = "unknown"; - var lines = std.mem.split(u8, content, "\n"); - while (lines.next()) |line| { - var fields = std.mem.split(u8, line, " "); - _ = fields.next() orelse continue; // device - const mount = fields.next() orelse continue; - const fs = fields.next() orelse continue; - - if (std.mem.eql(u8, mount, "/")) { - fs_type = try allocator.dupe(u8, fs); - break; - } - } - return DiskInfo{ .total = total, .used = used, - .fs_type = fs_type, .allocator = allocator, }; } diff --git a/pikafetch/src/system/info.zig b/pikafetch/src/system/info.zig index 311da0f..2ab477d 100644 --- a/pikafetch/src/system/info.zig +++ b/pikafetch/src/system/info.zig @@ -76,7 +76,6 @@ pub const SystemInfo = struct { cpu_info = try cpu.getCPUInfo(allocator); const swap_info = try memory.getSwapInfo(); const disk_info = try disk.getDiskInfo(allocator, "/"); - defer disk_info.deinit(); return SystemInfo{ .username = username.?, @@ -192,7 +191,7 @@ pub const SystemInfo = struct { calculations.usage_colors[1], calculations.swap_percentage, colors.Color.reset, }), - try std.fmt.allocPrint(self.allocator, "{s}Disk (/):{s} {d:.2} {s} / {d:.2} {s} ({s}{d}%{s}) - xfs", .{ + try std.fmt.allocPrint(self.allocator, "{s}Disk (/):{s} {d:.2} {s} / {d:.2} {s} ({s}{d}%{s})", .{ colors.Color.bold, colors.Color.reset, calculations.disk_fmt.value, calculations.disk_fmt.unit, calculations.disk_total_fmt.value, calculations.disk_total_fmt.unit,