| author | |
| committer | |
| log | 6ab156ce7dd781875db4965361418d8cdf4b3771 |
| tree | 996ac31b68a5f1663231143d81957c717327b90d |
| parent | 9b1b44b41c2b1efe272985af44eaae84b9c4af1c |
| parent | 25d9ab95dd8a691963453c4507d519051eaebb0c |
| signature |
Expose file inode number on posix and file index on windows8 files changed, 25 insertions(+), 5 deletions(-)
lib/std/fs/file.zig+12| ... | @@ -145,6 +145,16 @@ pub const File = struct { | ... | @@ -145,6 +145,16 @@ pub const File = struct { |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | pub const Stat = struct { | 147 | pub const Stat = struct { |
| 148 | /// A number that the system uses to point to the file metadata. This number is not guaranteed to be | ||
| 149 | /// unique across time, as some file systems may reuse an inode after it's file has been deleted. | ||
| 150 | /// Some systems may change the inode of a file over time. | ||
| 151 | /// | ||
| 152 | /// On Linux, the inode _is_ structure that stores the metadata, and the inode _number_ is what | ||
| 153 | /// you see here: the index number of the inode. | ||
| 154 | /// | ||
| 155 | /// The FileIndex on Windows is similar. It is a number for a file that is unique to each filesystem. | ||
| 156 | inode: os.ino_t, | ||
| 157 | |||
| 148 | size: u64, | 158 | size: u64, |
| 149 | mode: Mode, | 159 | mode: Mode, |
| 150 | 160 | ||
| ... | @@ -174,6 +184,7 @@ pub const File = struct { | ... | @@ -174,6 +184,7 @@ pub const File = struct { |
| 174 | else => return windows.unexpectedStatus(rc), | 184 | else => return windows.unexpectedStatus(rc), |
| 175 | } | 185 | } |
| 176 | return Stat{ | 186 | return Stat{ |
| 187 | .inode = info.InternalInformation.IndexNumber, | ||
| 177 | .size = @bitCast(u64, info.StandardInformation.EndOfFile), | 188 | .size = @bitCast(u64, info.StandardInformation.EndOfFile), |
| 178 | .mode = 0, | 189 | .mode = 0, |
| 179 | .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime), | 190 | .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime), |
| ... | @@ -187,6 +198,7 @@ pub const File = struct { | ... | @@ -187,6 +198,7 @@ pub const File = struct { |
| 187 | const mtime = st.mtime(); | 198 | const mtime = st.mtime(); |
| 188 | const ctime = st.ctime(); | 199 | const ctime = st.ctime(); |
| 189 | return Stat{ | 200 | return Stat{ |
| 201 | .inode = st.ino, | ||
| 190 | .size = @bitCast(u64, st.size), | 202 | .size = @bitCast(u64, st.size), |
| 191 | .mode = st.mode, | 203 | .mode = st.mode, |
| 192 | .atime = @as(i64, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec, | 204 | .atime = @as(i64, atime.tv_sec) * std.time.ns_per_s + atime.tv_nsec, |
lib/std/os/bits/darwin.zig+2-1| ... | @@ -53,6 +53,7 @@ pub const mach_timebase_info_data = extern struct { | ... | @@ -53,6 +53,7 @@ pub const mach_timebase_info_data = extern struct { |
| 53 | }; | 53 | }; |
| 54 | 54 | ||
| 55 | pub const off_t = i64; | 55 | pub const off_t = i64; |
| 56 | pub const ino_t = u64; | ||
| 56 | 57 | ||
| 57 | /// Renamed to Stat to not conflict with the stat function. | 58 | /// Renamed to Stat to not conflict with the stat function. |
| 58 | /// atime, mtime, and ctime have functions to return `timespec`, | 59 | /// atime, mtime, and ctime have functions to return `timespec`, |
| ... | @@ -64,7 +65,7 @@ pub const Stat = extern struct { | ... | @@ -64,7 +65,7 @@ pub const Stat = extern struct { |
| 64 | dev: i32, | 65 | dev: i32, |
| 65 | mode: u16, | 66 | mode: u16, |
| 66 | nlink: u16, | 67 | nlink: u16, |
| 67 | ino: u64, | 68 | ino: ino_t, |
| 68 | uid: u32, | 69 | uid: u32, |
| 69 | gid: u32, | 70 | gid: u32, |
| 70 | rdev: i32, | 71 | rdev: i32, |
lib/std/os/bits/dragonfly.zig+3-1| ... | @@ -138,8 +138,10 @@ pub const MAP_SIZEALIGN = 262144; | ... | @@ -138,8 +138,10 @@ pub const MAP_SIZEALIGN = 262144; |
| 138 | 138 | ||
| 139 | pub const PATH_MAX = 1024; | 139 | pub const PATH_MAX = 1024; |
| 140 | 140 | ||
| 141 | pub const ino_t = c_ulong; | ||
| 142 | |||
| 141 | pub const Stat = extern struct { | 143 | pub const Stat = extern struct { |
| 142 | ino: c_ulong, | 144 | ino: ino_t, |
| 143 | nlink: c_uint, | 145 | nlink: c_uint, |
| 144 | dev: c_uint, | 146 | dev: c_uint, |
| 145 | mode: c_ushort, | 147 | mode: c_ushort, |
lib/std/os/bits/freebsd.zig+2-1| ... | @@ -98,6 +98,7 @@ pub const msghdr_const = extern struct { | ... | @@ -98,6 +98,7 @@ pub const msghdr_const = extern struct { |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | pub const off_t = i64; | 100 | pub const off_t = i64; |
| 101 | pub const ino_t = u64; | ||
| 101 | 102 | ||
| 102 | /// Renamed to Stat to not conflict with the stat function. | 103 | /// Renamed to Stat to not conflict with the stat function. |
| 103 | /// atime, mtime, and ctime have functions to return `timespec`, | 104 | /// atime, mtime, and ctime have functions to return `timespec`, |
| ... | @@ -107,7 +108,7 @@ pub const off_t = i64; | ... | @@ -107,7 +108,7 @@ pub const off_t = i64; |
| 107 | /// methods to accomplish this. | 108 | /// methods to accomplish this. |
| 108 | pub const Stat = extern struct { | 109 | pub const Stat = extern struct { |
| 109 | dev: u64, | 110 | dev: u64, |
| 110 | ino: u64, | 111 | ino: ino_t, |
| 111 | nlink: usize, | 112 | nlink: usize, |
| 112 | 113 | ||
| 113 | mode: u16, | 114 | mode: u16, |
lib/std/os/bits/linux/x86_64.zig+2-1| ... | @@ -481,6 +481,7 @@ pub const msghdr_const = extern struct { | ... | @@ -481,6 +481,7 @@ pub const msghdr_const = extern struct { |
| 481 | }; | 481 | }; |
| 482 | 482 | ||
| 483 | pub const off_t = i64; | 483 | pub const off_t = i64; |
| 484 | pub const ino_t = u64; | ||
| 484 | 485 | ||
| 485 | /// Renamed to Stat to not conflict with the stat function. | 486 | /// Renamed to Stat to not conflict with the stat function. |
| 486 | /// atime, mtime, and ctime have functions to return `timespec`, | 487 | /// atime, mtime, and ctime have functions to return `timespec`, |
| ... | @@ -490,7 +491,7 @@ pub const off_t = i64; | ... | @@ -490,7 +491,7 @@ pub const off_t = i64; |
| 490 | /// methods to accomplish this. | 491 | /// methods to accomplish this. |
| 491 | pub const Stat = extern struct { | 492 | pub const Stat = extern struct { |
| 492 | dev: u64, | 493 | dev: u64, |
| 493 | ino: u64, | 494 | ino: ino_t, |
| 494 | nlink: usize, | 495 | nlink: usize, |
| 495 | 496 | ||
| 496 | mode: u32, | 497 | mode: u32, |
lib/std/os/bits/netbsd.zig+2-1| ... | @@ -69,6 +69,7 @@ pub const msghdr_const = extern struct { | ... | @@ -69,6 +69,7 @@ pub const msghdr_const = extern struct { |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | pub const off_t = i64; | 71 | pub const off_t = i64; |
| 72 | pub const ino_t = u64; | ||
| 72 | 73 | ||
| 73 | /// Renamed to Stat to not conflict with the stat function. | 74 | /// Renamed to Stat to not conflict with the stat function. |
| 74 | /// atime, mtime, and ctime have functions to return `timespec`, | 75 | /// atime, mtime, and ctime have functions to return `timespec`, |
| ... | @@ -79,7 +80,7 @@ pub const off_t = i64; | ... | @@ -79,7 +80,7 @@ pub const off_t = i64; |
| 79 | pub const Stat = extern struct { | 80 | pub const Stat = extern struct { |
| 80 | dev: u64, | 81 | dev: u64, |
| 81 | mode: u32, | 82 | mode: u32, |
| 82 | ino: u64, | 83 | ino: ino_t, |
| 83 | nlink: usize, | 84 | nlink: usize, |
| 84 | 85 | ||
| 85 | uid: u32, | 86 | uid: u32, |
lib/std/os/bits/wasi.zig+1| ... | @@ -178,6 +178,7 @@ pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004; | ... | @@ -178,6 +178,7 @@ pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004; |
| 178 | pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; | 178 | pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008; |
| 179 | 179 | ||
| 180 | pub const inode_t = u64; | 180 | pub const inode_t = u64; |
| 181 | pub const ino_t = inode_t; | ||
| 181 | 182 | ||
| 182 | pub const linkcount_t = u32; | 183 | pub const linkcount_t = u32; |
| 183 | 184 |
lib/std/os/bits/windows.zig+1| ... | @@ -4,6 +4,7 @@ usingnamespace @import("../windows/bits.zig"); | ... | @@ -4,6 +4,7 @@ usingnamespace @import("../windows/bits.zig"); |
| 4 | const ws2_32 = @import("../windows/ws2_32.zig"); | 4 | const ws2_32 = @import("../windows/ws2_32.zig"); |
| 5 | 5 | ||
| 6 | pub const fd_t = HANDLE; | 6 | pub const fd_t = HANDLE; |
| 7 | pub const ino_t = LARGE_INTEGER; | ||
| 7 | pub const pid_t = HANDLE; | 8 | pub const pid_t = HANDLE; |
| 8 | pub const mode_t = u0; | 9 | pub const mode_t = u0; |
| 9 | 10 |