mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #1146 from Arcterus/winapi
Improve support on Windows/Redox
This commit is contained in:
commit
3361fe94ec
21 changed files with 355 additions and 140 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,6 +4,7 @@ target/
|
|||
/tmp/
|
||||
/busybox/
|
||||
/.vscode/
|
||||
/.vs/
|
||||
*~
|
||||
.*.swp
|
||||
.*.swo
|
||||
|
|
97
Cargo.lock
generated
97
Cargo.lock
generated
|
@ -76,6 +76,11 @@ name = "bitflags"
|
|||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.0.1"
|
||||
|
@ -111,7 +116,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.4"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
|
@ -189,7 +194,7 @@ name = "cmake"
|
|||
version = "0.1.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -214,7 +219,7 @@ dependencies = [
|
|||
"quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uucore 0.0.1",
|
||||
"walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xattr 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
@ -344,6 +349,17 @@ dependencies = [
|
|||
"uucore 0.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "duct"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"os_pipe 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"shared_child 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "echo"
|
||||
version = "0.0.1"
|
||||
|
@ -378,7 +394,7 @@ name = "expr"
|
|||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"onig 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"onig 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uucore 0.0.1",
|
||||
]
|
||||
|
||||
|
@ -527,6 +543,7 @@ version = "0.0.1"
|
|||
dependencies = [
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uucore 0.0.1",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -593,6 +610,11 @@ name = "lazy_static"
|
|||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.37"
|
||||
|
@ -741,6 +763,17 @@ dependencies = [
|
|||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nl"
|
||||
version = "0.0.1"
|
||||
|
@ -839,25 +872,36 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "onig"
|
||||
version = "1.6.1"
|
||||
version = "3.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"onig_sys 65.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"onig_sys 67.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "onig_sys"
|
||||
version = "65.0.1"
|
||||
version = "67.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cmake 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"duct 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_pipe"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "0.0.1"
|
||||
|
@ -1057,7 +1101,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "rust-users"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/Arcterus/rust-users#ed91d55dc1fba6b3267519e885f7eb9df3051a19"
|
||||
source = "git+https://github.com/uutils/rust-users#ed91d55dc1fba6b3267519e885f7eb9df3051a19"
|
||||
dependencies = [
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -1120,6 +1164,16 @@ dependencies = [
|
|||
"generic-array 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shared_child"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shred"
|
||||
version = "0.0.1"
|
||||
|
@ -1207,7 +1261,7 @@ dependencies = [
|
|||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uucore 0.0.1",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1226,7 +1280,7 @@ dependencies = [
|
|||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uucore 0.0.1",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1486,6 +1540,7 @@ dependencies = [
|
|||
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1559,7 +1614,7 @@ dependencies = [
|
|||
"relpath 0.0.1",
|
||||
"rm 0.0.1",
|
||||
"rmdir 0.0.1",
|
||||
"rust-users 0.6.0 (git+https://github.com/Arcterus/rust-users)",
|
||||
"rust-users 0.6.0 (git+https://github.com/uutils/rust-users)",
|
||||
"seq 0.0.1",
|
||||
"shred 0.0.1",
|
||||
"shuf 0.0.1",
|
||||
|
@ -1654,7 +1709,7 @@ dependencies = [
|
|||
"advapi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"getopts 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"uucore 0.0.1",
|
||||
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1710,11 +1765,12 @@ dependencies = [
|
|||
"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
|
||||
"checksum bit-vec 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "02b4ff8b16e6076c3e14220b39fbc1fabb6737522281a388998046859400895f"
|
||||
"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d"
|
||||
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
|
||||
"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
|
||||
"checksum block-buffer 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1339a1042f5d9f295737ad4d9a6ab6bf81c84a933dba110b9200cd6d1448b814"
|
||||
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
|
||||
"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23"
|
||||
"checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0"
|
||||
"checksum cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9be26b24e988625409b19736d130f0c7d224f01d06454b5f81d8d23d6c1a618f"
|
||||
"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de"
|
||||
"checksum chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c20ebe0b2b08b0aeddba49c609fe7957ba2e33449882cb186a180bc60682fa9"
|
||||
"checksum clap 2.30.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1c07b9257a00f3fc93b7f3c417fc15607ec7a56823bc2c37ec744e266387de5b"
|
||||
|
@ -1728,6 +1784,7 @@ dependencies = [
|
|||
"checksum cpp_synom 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc8da5694233b646150c785118f77835ad0a49680c7f312a10ef30957c67b6d"
|
||||
"checksum data-encoding 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d867ddbf09de0b73e09ec798972fb7f870495a0893f6f736c1855448c5a56789"
|
||||
"checksum digest 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e5b29bf156f3f4b3c4f610a25ff69370616ae6e0657d416de22645483e72af0a"
|
||||
"checksum duct 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8c553d79f40e74f7f611e49bf3429b6760cff79596b61818291c27cc0b18549d"
|
||||
"checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3"
|
||||
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
"checksum filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f"
|
||||
|
@ -1745,19 +1802,22 @@ dependencies = [
|
|||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
|
||||
"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
|
||||
"checksum lazycell 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3b585b7a6811fb03aa10e74b278a0f00f8dd9b45dc681f148bb29fa5cb61859b"
|
||||
"checksum libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)" = "56aebce561378d99a0bb578f8cb15b6114d2a1814a6c7949bbe646d968bb4fa9"
|
||||
"checksum md5 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "daa1004633f76cdcd5a9d83ffcfe615e30ca7a2a638fcc8b8039a2dac21289d7"
|
||||
"checksum memchr 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "148fab2e51b4f1cfc66da2a7c32981d1d3c083a803978268bb11fe4b86925e7a"
|
||||
"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d"
|
||||
"checksum nix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "47e49f6982987135c5e9620ab317623e723bd06738fd85377e8d55f57c8b6487"
|
||||
"checksum nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c5afeb0198ec7be8569d666644b574345aad2e95a53baf3a532da3e0f3fb32"
|
||||
"checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2"
|
||||
"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
|
||||
"checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe"
|
||||
"checksum num-iter 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "4b226df12c5a59b63569dd57fafb926d91b385dfce33d8074a412411b689d593"
|
||||
"checksum num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3c2bd9b9d21e48e956b763c9f37134dc62d9e95da6edb3f672cacb6caf3cd3"
|
||||
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
|
||||
"checksum onig 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1271a3f93197303deda8aedcd96ed2dbb908f61c0954ae70bf7a42f536dc35d7"
|
||||
"checksum onig_sys 65.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fbdee58fb75f5b7749ebc8f601f570961eed595dfe4c2bb9a542e2f7ae20b946"
|
||||
"checksum onig 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bf9c54a94ac4d9f3eec22b189b8a727e2ded82aee21e8ae7ffbba2468739161b"
|
||||
"checksum onig_sys 67.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34d894e8da3390097d99eb197eac2ec443277551388eff0f97c5f789933350ee"
|
||||
"checksum os_pipe 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f547689aea1f11fac90333d573854a8e3e52a9160df1c42aefa8cd16734a3c0"
|
||||
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
|
||||
"checksum pretty-bytes 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "009d6edd2c1dbf2e1c0cd48a2f7766e03498d49ada7109a01c6911815c685316"
|
||||
"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
|
||||
|
@ -1770,13 +1830,14 @@ dependencies = [
|
|||
"checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e"
|
||||
"checksum remove_dir_all 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0882bc41b0ba6131c7f0ce97233b62d8099e3f3abc60d4938185d3e35439c0cc"
|
||||
"checksum remove_dir_all 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d2f806b0fcdabd98acd380dc8daef485e22bcb7cddc811d1337967f2528cf5"
|
||||
"checksum rust-users 0.6.0 (git+https://github.com/Arcterus/rust-users)" = "<none>"
|
||||
"checksum rust-users 0.6.0 (git+https://github.com/uutils/rust-users)" = "<none>"
|
||||
"checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7"
|
||||
"checksum semver 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3fdd61b85a0fa777f7fb7c454b9189b2941b110d1385ce84d7f76efdf1606a85"
|
||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||
"checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c"
|
||||
"checksum sha2 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d963c78ce367df26d7ea8b8cc655c651b42e8a1e584e869c1e17dae3ccb116a"
|
||||
"checksum sha3 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "26405905b6a56a94c60109cfda62610507ac14a65be531f5767dec5c5a8dd6a0"
|
||||
"checksum shared_child 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bcd5e483b3475af9bc2a35311c2f3bbf0bd98fde91410ab15a0d4ba3c3127b4e"
|
||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||
"checksum tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f73eebdb68c14bcb24aef74ea96079830e7fa7b31a6106e42ea7ee887c1e134e"
|
||||
"checksum tempfile 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "11ce2fe9db64b842314052e2421ac61a73ce41b898dc8e3750398b219c5fc1e0"
|
||||
|
|
15
Cargo.toml
15
Cargo.toml
|
@ -6,7 +6,6 @@ build = "build.rs"
|
|||
|
||||
[features]
|
||||
unix = [
|
||||
"arch",
|
||||
"chgrp",
|
||||
"chmod",
|
||||
"chown",
|
||||
|
@ -14,7 +13,6 @@ unix = [
|
|||
"du",
|
||||
"groups",
|
||||
"hostid",
|
||||
"hostname",
|
||||
"id",
|
||||
"install",
|
||||
"kill",
|
||||
|
@ -44,7 +42,6 @@ unix = [
|
|||
# all utilities in that feature.
|
||||
fuchsia = [
|
||||
# unix utilities
|
||||
"arch",
|
||||
"chgrp",
|
||||
"chmod",
|
||||
"chown",
|
||||
|
@ -67,8 +64,10 @@ fuchsia = [
|
|||
"generic"
|
||||
]
|
||||
generic = [
|
||||
"arch",
|
||||
"cat",
|
||||
"hashsum",
|
||||
"hostname",
|
||||
"join",
|
||||
"more",
|
||||
"ln",
|
||||
|
@ -84,14 +83,14 @@ generic = [
|
|||
"tail",
|
||||
"test",
|
||||
"whoami",
|
||||
"redox"
|
||||
"redox_generic"
|
||||
]
|
||||
# Feature "redox" contains the exclusive list of utilities
|
||||
# Feature "redox"/"redox_generic" contains the exclusive list of utilities
|
||||
# that can be compiled and run on redox. Should be built
|
||||
# with --no-default-features when selecting this feature.
|
||||
# TODO: merge with "generic" to avoid duplication once we support
|
||||
# all utilities in that feature.
|
||||
redox = [
|
||||
redox_generic = [
|
||||
|
||||
# And maybe all generic utilities
|
||||
"base32",
|
||||
|
@ -141,6 +140,10 @@ redox = [
|
|||
"wc",
|
||||
"yes",
|
||||
]
|
||||
redox = [
|
||||
"uname",
|
||||
"redox_generic"
|
||||
]
|
||||
test_unimplemented = []
|
||||
nightly = []
|
||||
default = ["generic", "unix"]
|
||||
|
|
2
build.rs
2
build.rs
|
@ -16,7 +16,7 @@ pub fn main() {
|
|||
if val == "1" && key.starts_with(feature_prefix) {
|
||||
let krate = key[feature_prefix.len()..].to_lowercase();
|
||||
match krate.as_ref() {
|
||||
"default" | "unix" | "redox" | "fuchsia" | "generic" | "nightly" | "test_unimplemented" => continue,
|
||||
"default" | "unix" | "redox" | "redox_generic" | "fuchsia" | "generic" | "nightly" | "test_unimplemented" => continue,
|
||||
_ => {},
|
||||
}
|
||||
crates.push(krate.to_string());
|
||||
|
|
|
@ -19,7 +19,7 @@ static LONG_HELP: &'static str = "";
|
|||
|
||||
pub fn uumain(args: Vec<String>) -> i32 {
|
||||
new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
|
||||
let uts = Uname::new();
|
||||
let uts = return_if_err!(1, Uname::new());
|
||||
println!("{}", uts.machine().trim());
|
||||
0
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ ioctl-sys = "0.5.2"
|
|||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
kernel32-sys = "0.2.2"
|
||||
winapi = "0.2"
|
||||
winapi = "0.3"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
xattr="0.2.1"
|
||||
|
|
|
@ -695,8 +695,8 @@ fn preserve_hardlinks(hard_links: &mut Vec<(String, u64)>, source: &std::path::P
|
|||
{
|
||||
let mut stat = mem::uninitialized();
|
||||
let handle = CreateFile2(src_path.as_ptr() as *const u16,
|
||||
winapi::winnt::GENERIC_READ,
|
||||
winapi::winnt::FILE_SHARE_READ,
|
||||
winapi::um::winnt::GENERIC_READ,
|
||||
winapi::um::winnt::FILE_SHARE_READ,
|
||||
0,
|
||||
std::ptr::null_mut());
|
||||
if GetFileInformationByHandle(handle, stat) != 0 {
|
||||
|
|
|
@ -10,7 +10,7 @@ path = "expr.rs"
|
|||
|
||||
[dependencies]
|
||||
libc = "0.2.26"
|
||||
onig = "1.3.0"
|
||||
onig = "3.1.1"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//!
|
||||
|
||||
use tokens::{Token};
|
||||
use onig::{Regex, Syntax, REGEX_OPTION_NONE};
|
||||
use onig::{Regex, RegexOptions, Syntax};
|
||||
|
||||
type TokenStack = Vec<(usize, Token)>;
|
||||
pub type OperandsList = Vec< Box<ASTNode> >;
|
||||
|
@ -354,7 +354,7 @@ fn infix_operator_and( values: &Vec<String> ) -> Result<String, String> {
|
|||
|
||||
fn operator_match(values: &Vec<String>) -> Result<String, String> {
|
||||
assert!(values.len() == 2);
|
||||
let re = match Regex::with_options(&values[1], REGEX_OPTION_NONE, Syntax::grep()) {
|
||||
let re = match Regex::with_options(&values[1], RegexOptions::REGEX_OPTION_NONE, Syntax::grep()) {
|
||||
Ok(m) => m,
|
||||
Err(err) => return Err(err.description().to_string())
|
||||
};
|
||||
|
|
|
@ -10,6 +10,7 @@ path = "hostname.rs"
|
|||
|
||||
[dependencies]
|
||||
libc = "0.2.26"
|
||||
winapi = { version = "0.3", features = ["sysinfoapi", "winsock2"] }
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
|
|
|
@ -7,41 +7,57 @@
|
|||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* Synced with:
|
||||
*
|
||||
* https://www.opensource.apple.com/source/shell_cmds/shell_cmds-170/hostname/hostname.c?txt
|
||||
*/
|
||||
|
||||
extern crate libc;
|
||||
#[cfg(windows)]
|
||||
extern crate winapi;
|
||||
|
||||
#[macro_use]
|
||||
extern crate uucore;
|
||||
|
||||
use std::collections::hash_set::HashSet;
|
||||
use std::iter::repeat;
|
||||
use std::io;
|
||||
use std::str;
|
||||
use std::net::ToSocketAddrs;
|
||||
|
||||
#[cfg(windows)]
|
||||
use winapi::um::winsock2::{GetHostNameW, WSAStartup, WSACleanup};
|
||||
#[cfg(windows)]
|
||||
use winapi::um::sysinfoapi::{ComputerNamePhysicalDnsHostname, SetComputerNameExW};
|
||||
#[cfg(windows)]
|
||||
use winapi::shared::minwindef::MAKEWORD;
|
||||
#[cfg(windows)]
|
||||
use uucore::wide::*;
|
||||
|
||||
#[cfg(not(windows))]
|
||||
use libc::gethostname;
|
||||
#[cfg(not(windows))]
|
||||
use libc::sethostname;
|
||||
|
||||
static SYNTAX: &'static str = "[OPTION]... [HOSTNAME]";
|
||||
static SUMMARY: &'static str = "Print or set the system's host name.";
|
||||
static LONG_HELP: &'static str = "";
|
||||
|
||||
extern {
|
||||
fn gethostname(name: *mut libc::c_char, namelen: libc::size_t) -> libc::c_int;
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
||||
extern {
|
||||
fn sethostname(name: *const libc::c_char, namelen: libc::c_int) -> libc::c_int;
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
extern {
|
||||
fn sethostname(name: *const libc::c_char, namelen: libc::size_t) -> libc::c_int;
|
||||
}
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> i32 {
|
||||
#[cfg(windows)]
|
||||
unsafe {
|
||||
let mut data = std::mem::uninitialized();
|
||||
if WSAStartup(MAKEWORD(2, 2), &mut data as *mut _) != 0 {
|
||||
eprintln!("Failed to start Winsock 2.2");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
let result = execute(args);
|
||||
#[cfg(windows)]
|
||||
unsafe {
|
||||
WSACleanup();
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn execute(args: Vec<String>) -> i32 {
|
||||
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP)
|
||||
.optflag("d", "domain", "Display the name of the DNS domain if possible")
|
||||
.optflag("i", "ip-address", "Display the network address(es) of the host")
|
||||
|
@ -51,7 +67,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
|
||||
match matches.free.len() {
|
||||
0 => {
|
||||
let hostname = xgethostname();
|
||||
let hostname = return_if_err!(1, xgethostname());
|
||||
|
||||
if matches.opt_present("i") {
|
||||
// XXX: to_socket_addrs needs hostname:port so append a dummy port and remove it later.
|
||||
|
@ -110,45 +126,63 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
0
|
||||
}
|
||||
|
||||
fn xgethostname() -> String {
|
||||
let namelen = 256usize;
|
||||
let mut name : Vec<u8> = repeat(0).take(namelen).collect();
|
||||
#[cfg(not(windows))]
|
||||
fn xgethostname() -> io::Result<String> {
|
||||
let namelen = 256;
|
||||
let mut name: Vec<u8> = repeat(0).take(namelen).collect();
|
||||
let err = unsafe {
|
||||
gethostname (name.as_mut_ptr() as *mut libc::c_char,
|
||||
namelen as libc::size_t)
|
||||
gethostname(name.as_mut_ptr() as *mut libc::c_char, namelen as libc::size_t)
|
||||
};
|
||||
|
||||
if err != 0 {
|
||||
panic!("Cannot determine hostname");
|
||||
if err == 0 {
|
||||
let last_char = name.iter().position(|byte| *byte == 0).unwrap_or(namelen);
|
||||
|
||||
Ok(str::from_utf8(&name[..last_char]).unwrap().to_owned())
|
||||
} else {
|
||||
Err(io::Error::last_os_error())
|
||||
}
|
||||
|
||||
let last_char = name.iter().position(|byte| *byte == 0).unwrap_or(namelen);
|
||||
|
||||
str::from_utf8(&name[..last_char]).unwrap().to_owned()
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
||||
#[cfg(windows)]
|
||||
fn xgethostname() -> io::Result<String> {
|
||||
let namelen = 256;
|
||||
let mut name: Vec<u16> = repeat(0).take(namelen).collect();
|
||||
let err = unsafe {
|
||||
GetHostNameW(name.as_mut_ptr(), namelen as libc::c_int)
|
||||
};
|
||||
|
||||
if err == 0 {
|
||||
Ok(String::from_wide_null(&name))
|
||||
} else {
|
||||
Err(io::Error::last_os_error())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn xsethostname(name: &str) {
|
||||
let vec_name: Vec<libc::c_char> = name.bytes().map(|c| c as libc::c_char).collect();
|
||||
|
||||
let err = unsafe {
|
||||
sethostname (vec_name.as_ptr(), vec_name.len() as libc::c_int)
|
||||
sethostname(vec_name.as_ptr(), vec_name.len() as _)
|
||||
};
|
||||
|
||||
if err != 0 {
|
||||
println!("Cannot set hostname to {}", name);
|
||||
eprintln!("Cannot set hostname to {}", name);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(windows)]
|
||||
fn xsethostname(name: &str) {
|
||||
let vec_name: Vec<libc::c_char> = name.bytes().map(|c| c as libc::c_char).collect();
|
||||
use std::ffi::OsStr;
|
||||
|
||||
let wide_name = OsStr::new(name).to_wide_null();
|
||||
|
||||
let err = unsafe {
|
||||
sethostname (vec_name.as_ptr(), vec_name.len() as libc::size_t)
|
||||
SetComputerNameExW(ComputerNamePhysicalDnsHostname, wide_name.as_ptr())
|
||||
};
|
||||
|
||||
if err != 0 {
|
||||
println!("Cannot set hostname to {}", name);
|
||||
if err == 0 {
|
||||
// NOTE: the above is correct, failure is when the function returns 0 apparently
|
||||
eprintln!("Cannot set hostname to {}", name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ path = "sync.rs"
|
|||
[dependencies]
|
||||
getopts = "0.2.14"
|
||||
libc = "0.2.26"
|
||||
winapi = "0.2.8"
|
||||
winapi = { version = "0.3", features = ["handleapi", "winerror"] }
|
||||
kernel32-sys = "0.2.2"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
|
|
|
@ -44,13 +44,17 @@ mod platform {
|
|||
extern crate kernel32;
|
||||
use std::{mem};
|
||||
use std::fs::OpenOptions;
|
||||
use std::io::{Write};
|
||||
use std::os::windows::prelude::*;
|
||||
use uucore::wide::{FromWide, ToWide};
|
||||
use self::winapi::um::winbase;
|
||||
use self::winapi::um::winnt;
|
||||
use self::winapi::shared::minwindef;
|
||||
use self::winapi::um::handleapi;
|
||||
use self::winapi::shared::winerror;
|
||||
|
||||
unsafe fn flush_volume(name: &str) {
|
||||
let name_wide = name.to_wide_null();
|
||||
if kernel32::GetDriveTypeW(name_wide.as_ptr()) == winapi::DRIVE_FIXED {
|
||||
if kernel32::GetDriveTypeW(name_wide.as_ptr()) == winbase::DRIVE_FIXED {
|
||||
let sliced_name = &name[..name.len() - 1]; // eliminate trailing backslash
|
||||
match OpenOptions::new().write(true).open(sliced_name) {
|
||||
Ok(file) => if kernel32::FlushFileBuffers(file.as_raw_handle()) == 0 {
|
||||
|
@ -61,10 +65,10 @@ mod platform {
|
|||
}
|
||||
}
|
||||
|
||||
unsafe fn find_first_volume() -> (String, winapi::HANDLE) {
|
||||
let mut name: [winapi::WCHAR; winapi::MAX_PATH] = mem::uninitialized();
|
||||
let handle = kernel32::FindFirstVolumeW(name.as_mut_ptr(), name.len() as winapi::DWORD);
|
||||
if handle == winapi::INVALID_HANDLE_VALUE {
|
||||
unsafe fn find_first_volume() -> (String, winnt::HANDLE) {
|
||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
||||
let handle = kernel32::FindFirstVolumeW(name.as_mut_ptr(), name.len() as minwindef::DWORD);
|
||||
if handle == handleapi::INVALID_HANDLE_VALUE {
|
||||
crash!(kernel32::GetLastError() as i32, "failed to find first volume");
|
||||
}
|
||||
(String::from_wide_null(&name), handle)
|
||||
|
@ -74,12 +78,12 @@ mod platform {
|
|||
let (first_volume, next_volume_handle) = find_first_volume();
|
||||
let mut volumes = vec![first_volume];
|
||||
loop {
|
||||
let mut name: [winapi::WCHAR; winapi::MAX_PATH] = mem::uninitialized();
|
||||
let mut name: [winnt::WCHAR; minwindef::MAX_PATH] = mem::uninitialized();
|
||||
if kernel32::FindNextVolumeW(
|
||||
next_volume_handle, name.as_mut_ptr(), name.len() as winapi::DWORD
|
||||
next_volume_handle, name.as_mut_ptr(), name.len() as minwindef::DWORD
|
||||
) == 0 {
|
||||
match kernel32::GetLastError() {
|
||||
winapi::ERROR_NO_MORE_FILES => {
|
||||
winerror::ERROR_NO_MORE_FILES => {
|
||||
kernel32::FindVolumeClose(next_volume_handle);
|
||||
return volumes
|
||||
},
|
||||
|
|
|
@ -12,7 +12,7 @@ path = "tail.rs"
|
|||
getopts = "0.2.14"
|
||||
kernel32-sys = "0.2.2"
|
||||
libc = "0.2.26"
|
||||
winapi = "0.2.8"
|
||||
winapi = "0.3"
|
||||
uucore = { path="../uucore" }
|
||||
|
||||
[[bin]]
|
||||
|
|
|
@ -11,9 +11,9 @@ extern crate winapi;
|
|||
extern crate kernel32;
|
||||
|
||||
use self::kernel32::{OpenProcess, CloseHandle, WaitForSingleObject};
|
||||
use self::winapi::minwindef::DWORD;
|
||||
use self::winapi::winbase::{WAIT_OBJECT_0, WAIT_FAILED};
|
||||
use self::winapi::winnt::{HANDLE, SYNCHRONIZE};
|
||||
use self::winapi::shared::minwindef::DWORD;
|
||||
use self::winapi::um::winbase::{WAIT_OBJECT_0, WAIT_FAILED};
|
||||
use self::winapi::um::winnt::{HANDLE, SYNCHRONIZE};
|
||||
|
||||
pub type Pid = DWORD;
|
||||
|
||||
|
|
|
@ -18,33 +18,35 @@ extern crate clap;
|
|||
use clap::{Arg, App};
|
||||
use uucore::utsname::Uname;
|
||||
|
||||
static VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||
static ABOUT: &'static str = "Print certain system information. With no OPTION, same as -s.";
|
||||
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
|
||||
const ABOUT: &'static str = "Print certain system information. With no OPTION, same as -s.";
|
||||
|
||||
static OPT_ALL: &'static str = "all";
|
||||
static OPT_KERNELNAME: &'static str = "kernel-name";
|
||||
static OPT_NODENAME: &'static str = "nodename";
|
||||
static OPT_KERNELVERSION: &'static str = "kernel-version";
|
||||
static OPT_KERNELRELEASE: &'static str = "kernel-release";
|
||||
static OPT_MACHINE: &'static str = "machine";
|
||||
const OPT_ALL: &'static str = "all";
|
||||
const OPT_KERNELNAME: &'static str = "kernel-name";
|
||||
const OPT_NODENAME: &'static str = "nodename";
|
||||
const OPT_KERNELVERSION: &'static str = "kernel-version";
|
||||
const OPT_KERNELRELEASE: &'static str = "kernel-release";
|
||||
const OPT_MACHINE: &'static str = "machine";
|
||||
|
||||
//FIXME: unimplemented options
|
||||
//static OPT_PROCESSOR: &'static str = "processor";
|
||||
//static OPT_HWPLATFORM: &'static str = "hardware-platform";
|
||||
static OPT_OS: &'static str = "operating-system";
|
||||
//const OPT_PROCESSOR: &'static str = "processor";
|
||||
//const OPT_HWPLATFORM: &'static str = "hardware-platform";
|
||||
const OPT_OS: &'static str = "operating-system";
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
static HOST_OS: &'static str = "GNU/Linux";
|
||||
const HOST_OS: &'static str = "GNU/Linux";
|
||||
#[cfg(target_os = "windows")]
|
||||
static HOST_OS: &'static str = "Windows NT";
|
||||
const HOST_OS: &'static str = "Windows NT";
|
||||
#[cfg(target_os = "freebsd")]
|
||||
static HOST_OS: &'static str = "FreeBSD";
|
||||
const HOST_OS: &'static str = "FreeBSD";
|
||||
#[cfg(target_os = "openbsd")]
|
||||
static HOST_OS: &'static str = "OpenBSD";
|
||||
const HOST_OS: &'static str = "OpenBSD";
|
||||
#[cfg(target_os = "macos")]
|
||||
static HOST_OS: &'static str = "Darwin";
|
||||
const HOST_OS: &'static str = "Darwin";
|
||||
#[cfg(target_os = "fuchsia")]
|
||||
static HOST_OS: &'static str = "Fuchsia";
|
||||
const HOST_OS: &'static str = "Fuchsia";
|
||||
#[cfg(target_os = "redox")]
|
||||
const HOST_OS: &'static str = "Redox";
|
||||
|
||||
pub fn uumain(args: Vec<String>) -> i32 {
|
||||
|
||||
|
@ -92,7 +94,7 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
.get_matches_from(&args);
|
||||
|
||||
let argc = args.len();
|
||||
let uname = Uname::new();
|
||||
let uname = return_if_err!(1, Uname::new());
|
||||
let mut output = String::new();
|
||||
|
||||
if matches.is_present(OPT_KERNELNAME) || matches.is_present(OPT_ALL) || argc == 1 {
|
||||
|
|
|
@ -8,6 +8,7 @@ getopts = "0.2.14"
|
|||
time = { version = "0.1.38", optional = true }
|
||||
data-encoding = { version = "^1.1", optional = true }
|
||||
libc = { version = "0.2.34", optional = true }
|
||||
winapi = { version = "0.3", features = ["sysinfoapi"], optional = true }
|
||||
|
||||
[features]
|
||||
fs = ["libc"]
|
||||
|
@ -20,7 +21,7 @@ process = ["libc"]
|
|||
signals = []
|
||||
entries = ["libc"]
|
||||
wide = []
|
||||
utsname = ["libc"]
|
||||
utsname = ["libc", "winapi"]
|
||||
default = ["fs", "libc", "utf8", "utsname", "encoding", "parse_time", "mode", "utmpx", "process", "entries", "signals", "wide"]
|
||||
|
||||
[lib]
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#[cfg(feature = "libc")]
|
||||
pub extern crate libc;
|
||||
#[cfg(feature = "winapi")]
|
||||
pub extern crate winapi;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
@ -22,7 +24,7 @@ pub mod parse_time;
|
|||
pub mod mode;
|
||||
#[cfg(all(unix, not(target_os = "fuchsia"), feature = "utmpx"))]
|
||||
pub mod utmpx;
|
||||
#[cfg(all(unix, feature = "utsname"))]
|
||||
#[cfg(feature = "utsname")]
|
||||
pub mod utsname;
|
||||
#[cfg(all(unix, feature = "entries"))]
|
||||
pub mod entries;
|
||||
|
|
|
@ -6,47 +6,150 @@
|
|||
// that was distributed with this source code.
|
||||
//
|
||||
|
||||
use super::libc::{uname, utsname};
|
||||
use ::std::mem;
|
||||
use ::std::ffi::CStr;
|
||||
use ::std::borrow::Cow;
|
||||
pub use self::platform::*;
|
||||
|
||||
macro_rules! cstr2cow {
|
||||
($v:expr) => (
|
||||
unsafe { CStr::from_ptr($v.as_ref().as_ptr()).to_string_lossy() }
|
||||
)
|
||||
}
|
||||
#[cfg(unix)]
|
||||
mod platform {
|
||||
use ::libc::{uname, utsname};
|
||||
use ::std::mem;
|
||||
use ::std::ffi::CStr;
|
||||
use ::std::borrow::Cow;
|
||||
use ::std::io;
|
||||
|
||||
pub struct Uname {
|
||||
inner: utsname,
|
||||
}
|
||||
macro_rules! cstr2cow {
|
||||
($v:expr) => (
|
||||
unsafe { CStr::from_ptr($v.as_ref().as_ptr()).to_string_lossy() }
|
||||
)
|
||||
}
|
||||
|
||||
impl Uname {
|
||||
pub fn new() -> Self {
|
||||
unsafe {
|
||||
let mut uts: utsname = mem::uninitialized();
|
||||
uname(&mut uts);
|
||||
Uname { inner: uts }
|
||||
pub struct Uname {
|
||||
inner: utsname,
|
||||
}
|
||||
|
||||
impl Uname {
|
||||
pub fn new() -> io::Result<Self> {
|
||||
unsafe {
|
||||
let mut uts: utsname = mem::uninitialized();
|
||||
if uname(&mut uts) == 0 {
|
||||
Ok(Uname { inner: uts })
|
||||
} else {
|
||||
Err(io::Error::last_os_error())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sysname(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.sysname)
|
||||
}
|
||||
|
||||
pub fn nodename(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.nodename)
|
||||
}
|
||||
|
||||
pub fn release(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.release)
|
||||
}
|
||||
|
||||
pub fn version(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.version)
|
||||
}
|
||||
|
||||
pub fn machine(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.machine)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sysname(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.sysname)
|
||||
#[cfg(windows)]
|
||||
mod platform {
|
||||
use ::winapi::um::sysinfoapi::{SYSTEM_INFO, GetSystemInfo};
|
||||
use ::winapi::um::winnt::*;
|
||||
use ::std::mem;
|
||||
use ::std::borrow::Cow;
|
||||
use ::std::io;
|
||||
|
||||
pub struct Uname {
|
||||
inner: SYSTEM_INFO
|
||||
}
|
||||
|
||||
pub fn nodename(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.nodename)
|
||||
}
|
||||
impl Uname {
|
||||
pub fn new() -> io::Result<Uname> {
|
||||
unsafe {
|
||||
let mut info = mem::uninitialized();
|
||||
GetSystemInfo(&mut info);
|
||||
Ok(Uname { inner: info })
|
||||
}
|
||||
}
|
||||
|
||||
pub fn release(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.release)
|
||||
}
|
||||
|
||||
pub fn version(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.version)
|
||||
}
|
||||
|
||||
pub fn machine(&self) -> Cow<str> {
|
||||
cstr2cow!(self.inner.machine)
|
||||
// FIXME: need to implement more architectures (e.g. ARM)
|
||||
pub fn machine(&self) -> Cow<str> {
|
||||
let arch = unsafe {
|
||||
match self.inner.u.s().wProcessorArchitecture {
|
||||
PROCESSOR_ARCHITECTURE_AMD64 => "x86_64",
|
||||
PROCESSOR_ARCHITECTURE_INTEL => "x86",
|
||||
_ => unimplemented!()
|
||||
}
|
||||
};
|
||||
Cow::from(arch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "redox")]
|
||||
mod platform {
|
||||
use ::std::borrow::Cow;
|
||||
use ::std::io::{self, Read};
|
||||
use ::std::fs::File;
|
||||
|
||||
pub struct Uname {
|
||||
kernel_name: String,
|
||||
nodename: String,
|
||||
kernel_release: String,
|
||||
kernel_version: String,
|
||||
machine: String
|
||||
}
|
||||
|
||||
impl Uname {
|
||||
pub fn new() -> io::Result<Uname> {
|
||||
let mut inner = String::new();
|
||||
File::open("sys:uname")?.read_to_string(&mut inner)?;
|
||||
|
||||
let mut lines = inner.lines();
|
||||
|
||||
let kernel_name = lines.next().unwrap();
|
||||
let nodename = lines.next().unwrap();
|
||||
let kernel_release = lines.next().unwrap();
|
||||
let kernel_version = lines.next().unwrap();
|
||||
let machine = lines.next().unwrap();
|
||||
|
||||
// FIXME: don't actually duplicate the data as doing so is wasteful
|
||||
Ok(Uname {
|
||||
kernel_name: kernel_name.to_owned(),
|
||||
nodename: nodename.to_owned(),
|
||||
kernel_release: kernel_release.to_owned(),
|
||||
kernel_version: kernel_version.to_owned(),
|
||||
machine: machine.to_owned()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn sysname(&self) -> Cow<str> {
|
||||
Cow::from(self.kernel_name.as_str())
|
||||
}
|
||||
|
||||
pub fn nodename(&self) -> Cow<str> {
|
||||
Cow::from(self.nodename.as_str())
|
||||
}
|
||||
|
||||
pub fn release(&self) -> Cow<str> {
|
||||
Cow::from(self.kernel_release.as_str())
|
||||
}
|
||||
|
||||
pub fn version(&self) -> Cow<str> {
|
||||
Cow::from(self.kernel_version.as_str())
|
||||
}
|
||||
|
||||
pub fn machine(&self) -> Cow<str> {
|
||||
Cow::from(self.machine.as_str())
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ path = "whoami.rs"
|
|||
|
||||
[dependencies]
|
||||
getopts = "0.2.14"
|
||||
winapi = "0.2.8"
|
||||
winapi = { version = "0.3", features = ["lmcons"] }
|
||||
advapi32-sys = "0.2.0"
|
||||
|
||||
[dependencies.uucore]
|
||||
|
|
|
@ -14,10 +14,13 @@ extern crate uucore;
|
|||
use std::io::{Error, Result};
|
||||
use std::mem;
|
||||
use uucore::wide::FromWide;
|
||||
use self::winapi::um::winnt;
|
||||
use self::winapi::shared::lmcons;
|
||||
use self::winapi::shared::minwindef;
|
||||
|
||||
pub unsafe fn getusername() -> Result<String> {
|
||||
let mut buffer: [winapi::WCHAR; winapi::UNLEN as usize + 1] = mem::uninitialized();
|
||||
let mut len = buffer.len() as winapi::DWORD;
|
||||
let mut buffer: [winnt::WCHAR; lmcons::UNLEN as usize + 1] = mem::uninitialized();
|
||||
let mut len = buffer.len() as minwindef::DWORD;
|
||||
if advapi32::GetUserNameW(buffer.as_mut_ptr(), &mut len) == 0 {
|
||||
return Err(Error::last_os_error())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue