Commit Graph

886 Commits

Author SHA1 Message Date
Wolfgang Bumiller
bd4a6c5b8b sys: use a BTreeMap for MountInfo internally
Since the only reasonable access is by mount "id" and they
don't need to be consecutive (but they are numeric), use a
BTreeMap for MountInfo.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 15:15:52 +01:00
Wolfgang Bumiller
4e27ec9eb1 sys: export MountInfo in procfs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 14:56:03 +01:00
Wolfgang Bumiller
775c96f934 sys: more helpers for MountInfo
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 14:54:51 +01:00
Wolfgang Bumiller
40da8098df sys: add /proc/self/mountinfo parsing
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 14:41:21 +01:00
Wolfgang Bumiller
e128fc879f sys: Add TryFrom<Pid> for PidStat
Since nix's Pid type is a strong type, we can add a TryFrom
implementation here as well.
This can later also have the equivalent TryFrom<PidFd>
variant.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 12:05:04 +01:00
Wolfgang Bumiller
42a155668e sys: change PidStat API
Rather than standalone functions, `PidStat` now provides a
`read_for_pid` and `parse` method. Both are public.
One side effect is that the documentation of PidStat's
contents are on the same page as the ways to retrieve it.

Additionally, we deprecate `read_proc_starttime` as it was
reading the entire contents to then filter out one value, in
order to promote caching.

The standalone `read_proc_pid_stat` method is now also
deprecated.

Once we add pid-fds the API will feel cleaner this way.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 12:01:06 +01:00
Wolfgang Bumiller
e3b41dc815 sys: extend proc_pid_stat parsing
Rename `ProcFsPidStat` to `PidStat`. It's already in a
procfs submodule anyway. (We have currently no public users
of this type by name.)

Further add pid, ppid and num_threads to PidStat.

Public API change.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 11:49:33 +01:00
Wolfgang Bumiller
39c5d8641b take a reference to the dirfd in Fd::openat
Otherwise we cannot pass references to it unless the AsRawFd
implementation was made for the reference itself rather than
the type.

Note that while this changes the public API, we have no
users outside of this crate yet and no public releases,
so I'm not doing a major version bump.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-14 11:24:32 +01:00
Wolfgang Bumiller
2a43a45763 fixup provides list
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 14:26:12 +01:00
Wolfgang Bumiller
02c7ca5163 finish version bump
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 14:21:39 +01:00
Wolfgang Bumiller
eae447156b bump proxmox to 0.1.2
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 14:14:11 +01:00
Wolfgang Bumiller
66d9d43cd4 bump api-macro to 0.1.1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:29:15 +01:00
Wolfgang Bumiller
1992abf96e api-macro: even more documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:28:00 +01:00
Wolfgang Bumiller
0f630a4cb8 api-macro: more documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:23:48 +01:00
Wolfgang Bumiller
5b652dbad8 api-macro: schema tests for async fns
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 11:01:55 +01:00
Wolfgang Bumiller
943bc4de52 api-macro: more tests
Note that this one tests the fact that we do not do output
schema validation!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:58:27 +01:00
Wolfgang Bumiller
58158b495e api-macro: more invocation tests for api methods
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:56:45 +01:00
Wolfgang Bumiller
679ad01c03 api-macro: add expanded data to tests for verification
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:51:00 +01:00
Wolfgang Bumiller
b0ef405186 api: add test-harness feature
If enabled, the Schema type implements Eq and PartialEq for
testing the api macro better.

Note that these implementations don't make all too much
since since they also compare `dyn Fn` types which do not
implement Eq. Since they're also `&'static` they can't
really be runtime closures, so this should be fine, we know
they'll always point to some regular function.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:38:30 +01:00
Wolfgang Bumiller
08e1cf3c2f api-macro: support empty api macro on structs
The description comes from the doc comment, the field types
and description from field doc comments and types.
Previously we needed to add at least the hint that the
schema is an object schema. Now we support an empty #[api]
attribute as well.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:09:42 +01:00
Wolfgang Bumiller
7c6ebbdbf3 api-macro: support renamed struct fields
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-08 10:06:48 +01:00
Wolfgang Bumiller
2e63bf8422 api-macro: support rename_all in enums
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:29:56 +01:00
Wolfgang Bumiller
dd5cd3f311 api-macro: start using serde attribute helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:23:52 +01:00
Wolfgang Bumiller
799c993d63 api-macro: prepare to support serde::rename_all
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 15:17:20 +01:00
Wolfgang Bumiller
3626f57d2c api-macro: more option type handling
infer_type now also returns whether it was encapsualted in
an Option<>. So `type: String, optional: true` is now
inferred propertly from `Option<String>`.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:37:34 +01:00
Wolfgang Bumiller
45af06f090 api-macro: derive optional values correctly
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:19:13 +01:00
Wolfgang Bumiller
46fe5832fb api-macro: reorganize field iteration
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:18:21 +01:00
Wolfgang Bumiller
9207e8aa9a api-macro: error on extraneous fields
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:16:12 +01:00
Wolfgang Bumiller
860a4fd0ad api-macro: add basic struct handling
- handle doc comments for descriptions
- infer fields from structs when possible
- perform some basic error checking

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:09:20 +01:00
Wolfgang Bumiller
e960a68b60 api-macro: factor out type inference for reuse with structs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 13:09:08 +01:00
Wolfgang Bumiller
b9769de6b6 api-macro: split struct handling into newtype, regular, unit, ...
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 12:11:04 +01:00
Wolfgang Bumiller
4c77a7fece api-macro: derive descriptions for structs
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-07 12:00:17 +01:00
Fabian Grünbichler
a6f21e7694 cargo: switch to use packaged crates by default
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-03 09:39:52 +01:00
Fabian Grünbichler
f667873d70 tools: remove accidentally commited debian/files
it's a build artifact, no need to version control it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-03 07:28:24 +01:00
Wolfgang Bumiller
43682dd416 version bump
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 14:42:28 +01:00
Wolfgang Bumiller
f214bcb652 api-macro: drop unused dev-dependencies
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 14:25:09 +01:00
Fabian Grünbichler
8bd5e82012 readme: add cargo config for packaged crates
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-02 14:07:12 +01:00
Fabian Grünbichler
94168b94c2 proxmox-tools: reference valgrind_request via git
to allow using 'cargo XXX' with cargo config pointing to packaged
sources instead of crates.io

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-01-02 14:00:27 +01:00
Wolfgang Bumiller
b659584f23 sys: add a bunch of error helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 13:47:53 +01:00
Wolfgang Bumiller
568ce10624 sys: add some helpful macros
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 13:47:53 +01:00
Wolfgang Bumiller
c52794b8ad api-macro: bump bytes to 0.5
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-02 12:45:07 +01:00
Wolfgang Bumiller
1a2aaad5a1 more versioning fixups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 12:33:13 +01:00
Wolfgang Bumiller
929161f030 -dev bump for proxmox crate as well
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 12:05:57 +01:00
Wolfgang Bumiller
496afe891e add a 'Versioning' readme section
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 11:50:30 +01:00
Wolfgang Bumiller
09345ac8c5 bump proxmox-tools to 0.1.1-dev.1
We now use this between package releases.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 11:32:21 +01:00
Wolfgang Bumiller
f90cbb7edd tools: fs: default to 644 for mode in replace_file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-12-30 10:06:40 +01:00
Fabian Grünbichler
c27369e136 proxmox: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
8840877c80 proxmox-api-macro: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
57565a5061 proxmox-sortable-macro: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00
Fabian Grünbichler
d6bf884814 proxmox-sys: initial packaging
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-12-20 09:39:45 +01:00