mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-05 18:03:01 +00:00
tools: fs: import unistd::{Uid,Gid} fully
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
0eadf624e0
commit
acbf549bf0
@ -5,7 +5,7 @@ use std::path::Path;
|
|||||||
|
|
||||||
use failure::{bail, format_err, Error};
|
use failure::{bail, format_err, Error};
|
||||||
use nix::sys::stat;
|
use nix::sys::stat;
|
||||||
use nix::unistd;
|
use nix::unistd::{self, Gid, Uid};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use super::try_block;
|
use super::try_block;
|
||||||
@ -80,8 +80,8 @@ pub fn file_set_contents_full<P: AsRef<Path>>(
|
|||||||
path: P,
|
path: P,
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
perm: Option<stat::Mode>,
|
perm: Option<stat::Mode>,
|
||||||
owner: Option<unistd::Uid>,
|
owner: Option<Uid>,
|
||||||
group: Option<unistd::Gid>,
|
group: Option<Gid>,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let path = path.as_ref();
|
let path = path.as_ref();
|
||||||
|
|
||||||
@ -130,11 +130,7 @@ pub fn file_set_contents_full<P: AsRef<Path>>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Change ownership of an open file handle
|
/// Change ownership of an open file handle
|
||||||
pub fn fchown(
|
pub fn fchown(fd: RawFd, owner: Option<Uid>, group: Option<Gid>) -> Result<(), Error> {
|
||||||
fd: RawFd,
|
|
||||||
owner: Option<nix::unistd::Uid>,
|
|
||||||
group: Option<nix::unistd::Gid>,
|
|
||||||
) -> Result<(), Error> {
|
|
||||||
// According to the POSIX specification, -1 is used to indicate that owner and group
|
// According to the POSIX specification, -1 is used to indicate that owner and group
|
||||||
// are not to be changed. Since uid_t and gid_t are unsigned types, we have to wrap
|
// are not to be changed. Since uid_t and gid_t are unsigned types, we have to wrap
|
||||||
// around to get -1 (copied fron nix crate).
|
// around to get -1 (copied fron nix crate).
|
||||||
@ -157,8 +153,8 @@ pub fn fchown(
|
|||||||
pub fn create_dir_chown<P: AsRef<Path>>(
|
pub fn create_dir_chown<P: AsRef<Path>>(
|
||||||
path: P,
|
path: P,
|
||||||
perm: Option<stat::Mode>,
|
perm: Option<stat::Mode>,
|
||||||
owner: Option<unistd::Uid>,
|
owner: Option<Uid>,
|
||||||
group: Option<unistd::Gid>,
|
group: Option<Gid>,
|
||||||
) -> Result<(), nix::Error> {
|
) -> Result<(), nix::Error> {
|
||||||
let mode: stat::Mode = perm.unwrap_or(stat::Mode::from_bits_truncate(0o770));
|
let mode: stat::Mode = perm.unwrap_or(stat::Mode::from_bits_truncate(0o770));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user