| ... | @@ -19,6 +19,8 @@ pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; | ... | @@ -19,6 +19,8 @@ pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int; |
| 19 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; | 19 | pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: usize) c_int; |
| 20 | pub extern "c" fn malloc_usable_size(?*const anyopaque) usize; | 20 | pub extern "c" fn malloc_usable_size(?*const anyopaque) usize; |
| 21 | | 21 | |
| | 22 | pub extern "c" fn getpid() pid_t; |
| | 23 | |
| 22 | pub const sf_hdtr = extern struct { | 24 | pub const sf_hdtr = extern struct { |
| 23 | headers: [*]const iovec_const, | 25 | headers: [*]const iovec_const, |
| 24 | hdr_cnt: c_int, | 26 | hdr_cnt: c_int, |
| ... | @@ -397,6 +399,127 @@ pub const sockaddr = extern struct { | ... | @@ -397,6 +399,127 @@ pub const sockaddr = extern struct { |
| 397 | }; | 399 | }; |
| 398 | }; | 400 | }; |
| 399 | | 401 | |
| | 402 | pub const CAP_RIGHTS_VERSION = 0; |
| | 403 | |
| | 404 | pub const cap_rights = extern struct { |
| | 405 | rights: [CAP_RIGHTS_VERSION + 2]u64, |
| | 406 | }; |
| | 407 | |
| | 408 | pub const kinfo_file = extern struct { |
| | 409 | /// Size of this record. |
| | 410 | /// A zero value is for the sentinel record at the end of an array. |
| | 411 | structsize: c_int, |
| | 412 | /// Descriptor type. |
| | 413 | @"type": c_int, |
| | 414 | /// Array index. |
| | 415 | fd: fd_t, |
| | 416 | /// Reference count. |
| | 417 | ref_count: c_int, |
| | 418 | /// Flags. |
| | 419 | flags: c_int, |
| | 420 | // 64bit padding. |
| | 421 | _pad0: c_int, |
| | 422 | /// Seek location. |
| | 423 | offset: i64, |
| | 424 | un: extern union { |
| | 425 | socket: extern struct { |
| | 426 | /// Sendq size. |
| | 427 | sendq: u32, |
| | 428 | /// Socket domain. |
| | 429 | domain: c_int, |
| | 430 | /// Socket type. |
| | 431 | @"type": c_int, |
| | 432 | /// Socket protocol. |
| | 433 | protocol: c_int, |
| | 434 | /// Socket address. |
| | 435 | address: sockaddr.storage, |
| | 436 | /// Peer address. |
| | 437 | peer: sockaddr.storage, |
| | 438 | /// Address of so_pcb. |
| | 439 | pcb: u64, |
| | 440 | /// Address of inp_ppcb. |
| | 441 | inpcb: u64, |
| | 442 | /// Address of unp_conn. |
| | 443 | unpconn: u64, |
| | 444 | /// Send buffer state. |
| | 445 | snd_sb_state: u16, |
| | 446 | /// Receive buffer state. |
| | 447 | rcv_sb_state: u16, |
| | 448 | /// Recvq size. |
| | 449 | recvq: u32, |
| | 450 | }, |
| | 451 | file: extern struct { |
| | 452 | /// Vnode type. |
| | 453 | @"type": i32, |
| | 454 | // Reserved for future use |
| | 455 | _spare1: [3]i32, |
| | 456 | _spare2: [30]u64, |
| | 457 | /// Vnode filesystem id. |
| | 458 | fsid: u64, |
| | 459 | /// File device. |
| | 460 | rdev: u64, |
| | 461 | /// Global file id. |
| | 462 | fileid: u64, |
| | 463 | /// File size. |
| | 464 | size: u64, |
| | 465 | /// fsid compat for FreeBSD 11. |
| | 466 | fsid_freebsd11: u32, |
| | 467 | /// rdev compat for FreeBSD 11. |
| | 468 | rdev_freebsd11: u32, |
| | 469 | /// File mode. |
| | 470 | mode: u16, |
| | 471 | // 64bit padding. |
| | 472 | _pad0: u16, |
| | 473 | _pad1: u32, |
| | 474 | }, |
| | 475 | sem: extern struct { |
| | 476 | _spare0: [4]u32, |
| | 477 | _spare1: [32]u64, |
| | 478 | /// Semaphore value. |
| | 479 | value: u32, |
| | 480 | /// Semaphore mode. |
| | 481 | mode: u16, |
| | 482 | }, |
| | 483 | pipe: extern struct { |
| | 484 | _spare1: [4]u32, |
| | 485 | _spare2: [32]u64, |
| | 486 | addr: u64, |
| | 487 | peer: u64, |
| | 488 | buffer_cnt: u32, |
| | 489 | // 64bit padding. |
| | 490 | kf_pipe_pad0: [3]u32, |
| | 491 | }, |
| | 492 | proc: extern struct { |
| | 493 | _spare1: [4]u32, |
| | 494 | _spare2: [32]u64, |
| | 495 | pid: pid_t, |
| | 496 | }, |
| | 497 | eventfd: extern struct { |
| | 498 | value: u64, |
| | 499 | flags: u32, |
| | 500 | }, |
| | 501 | }, |
| | 502 | /// Status flags. |
| | 503 | status: u16, |
| | 504 | // 32-bit alignment padding. |
| | 505 | _pad1: u16, |
| | 506 | // Reserved for future use. |
| | 507 | _spare: c_int, |
| | 508 | /// Capability rights. |
| | 509 | cap_rights: cap_rights, |
| | 510 | /// Reserved for future cap_rights |
| | 511 | _cap_spare: u64, |
| | 512 | /// Path to file, if any. |
| | 513 | path: [PATH_MAX - 1:0]u8, |
| | 514 | }; |
| | 515 | |
| | 516 | pub const KINFO_FILE_SIZE = 1392; |
| | 517 | |
| | 518 | comptime { |
| | 519 | std.debug.assert(@sizeOf(kinfo_file) == KINFO_FILE_SIZE); |
| | 520 | std.debug.assert(@alignOf(kinfo_file) == @sizeOf(u64)); |
| | 521 | } |
| | 522 | |
| 400 | pub const CTL = struct { | 523 | pub const CTL = struct { |
| 401 | pub const KERN = 1; | 524 | pub const KERN = 1; |
| 402 | pub const DEBUG = 5; | 525 | pub const DEBUG = 5; |
| ... | @@ -405,6 +528,7 @@ pub const CTL = struct { | ... | @@ -405,6 +528,7 @@ pub const CTL = struct { |
| 405 | pub const KERN = struct { | 528 | pub const KERN = struct { |
| 406 | pub const PROC = 14; // struct: process entries | 529 | pub const PROC = 14; // struct: process entries |
| 407 | pub const PROC_PATHNAME = 12; // path to executable | 530 | pub const PROC_PATHNAME = 12; // path to executable |
| | 531 | pub const PROC_FILEDESC = 33; // file descriptors for process |
| 408 | pub const IOV_MAX = 35; | 532 | pub const IOV_MAX = 35; |
| 409 | }; | 533 | }; |
| 410 | | 534 | |
| ... | @@ -613,23 +737,67 @@ pub const O = struct { | ... | @@ -613,23 +737,67 @@ pub const O = struct { |
| 613 | pub const NDELAY = NONBLOCK; | 737 | pub const NDELAY = NONBLOCK; |
| 614 | }; | 738 | }; |
| 615 | | 739 | |
| | 740 | /// Command flags for fcntl(2). |
| 616 | pub const F = struct { | 741 | pub const F = struct { |
| | 742 | /// Duplicate file descriptor. |
| 617 | pub const DUPFD = 0; | 743 | pub const DUPFD = 0; |
| | 744 | /// Get file descriptor flags. |
| 618 | pub const GETFD = 1; | 745 | pub const GETFD = 1; |
| | 746 | /// Set file descriptor flags. |
| 619 | pub const SETFD = 2; | 747 | pub const SETFD = 2; |
| | 748 | /// Get file status flags. |
| 620 | pub const GETFL = 3; | 749 | pub const GETFL = 3; |
| | 750 | /// Set file status flags. |
| 621 | pub const SETFL = 4; | 751 | pub const SETFL = 4; |
| 622 | | 752 | |
| | 753 | /// Get SIGIO/SIGURG proc/pgrrp. |
| 623 | pub const GETOWN = 5; | 754 | pub const GETOWN = 5; |
| | 755 | /// Set SIGIO/SIGURG proc/pgrrp. |
| 624 | pub const SETOWN = 6; | 756 | pub const SETOWN = 6; |
| 625 | | 757 | |
| | 758 | /// Get record locking information. |
| 626 | pub const GETLK = 11; | 759 | pub const GETLK = 11; |
| | 760 | /// Set record locking information. |
| 627 | pub const SETLK = 12; | 761 | pub const SETLK = 12; |
| | 762 | /// Set record locking information and wait if blocked. |
| 628 | pub const SETLKW = 13; | 763 | pub const SETLKW = 13; |
| 629 | | 764 | |
| | 765 | /// Debugging support for remote locks. |
| | 766 | pub const SETLK_REMOTE = 14; |
| | 767 | /// Read ahead. |
| | 768 | pub const READAHEAD = 15; |
| | 769 | |
| | 770 | /// DUPFD with FD_CLOEXEC set. |
| | 771 | pub const DUPFD_CLOEXEC = 17; |
| | 772 | /// DUP2FD with FD_CLOEXEC set. |
| | 773 | pub const DUP2FD_CLOEXEC = 18; |
| | 774 | |
| | 775 | pub const ADD_SEALS = 19; |
| | 776 | pub const GET_SEALS = 20; |
| | 777 | /// Return `kinfo_file` for a file descriptor. |
| | 778 | pub const KINFO = 22; |
| | 779 | |
| | 780 | // Seals (ADD_SEALS, GET_SEALS) |
| | 781 | /// Prevent adding sealings. |
| | 782 | pub const SEAL_SEAL = 0x0001; |
| | 783 | /// May not shrink |
| | 784 | pub const SEAL_SHRINK = 0x0002; |
| | 785 | /// May not grow. |
| | 786 | pub const SEAL_GROW = 0x0004; |
| | 787 | /// May not write. |
| | 788 | pub const SEAL_WRITE = 0x0008; |
| | 789 | |
| | 790 | // Record locking flags (GETLK, SETLK, SETLKW). |
| | 791 | /// Shared or read lock. |
| 630 | pub const RDLCK = 1; | 792 | pub const RDLCK = 1; |
| 631 | pub const WRLCK = 3; | 793 | /// Unlock. |
| 632 | pub const UNLCK = 2; | 794 | pub const UNLCK = 2; |
| | 795 | /// Exclusive or write lock. |
| | 796 | pub const WRLCK = 3; |
| | 797 | /// Purge locks for a given system ID. |
| | 798 | pub const UNLCKSYS = 4; |
| | 799 | /// Cancel an async lock request. |
| | 800 | pub const CANCEL = 5; |
| 633 | | 801 | |
| 634 | pub const SETOWN_EX = 15; | 802 | pub const SETOWN_EX = 15; |
| 635 | pub const GETOWN_EX = 16; | 803 | pub const GETOWN_EX = 16; |