Commit 901aab8761

Luna <git@l4.pm>
2020-03-29 22:45:43
Add ioctl errors
1 parent 2c641c9
Changed files (1)
lib
lib/std/net.zig
@@ -533,7 +533,18 @@ fn if_nametoindex(name: []const u8) !u32 {
         @ptrToInt(&ifr),
     );
 
-    return ifr.ifr_ifru.ifru_ivalue;
+    switch (os.errno(rc)) {
+        os.EBADF => return error.BadFile,
+        os.EINTR => return error.CaughtSignal,
+        os.EINVAL => unreachable,
+        os.EIO => return error.FileSystem,
+        os.ENOTTY => unreachable,
+        os.ENXIO => unreachable,
+        os.ENODEV => return error.Unsupported,
+        else => {},
+    }
+
+    return @bitCast(u32, ifr.ifr_ifru.ifru_ivalue);
 }
 
 pub const AddressList = struct {