some quotactl preparation

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2019-07-12 10:23:02 +02:00
parent 7970b0ea8d
commit 3e69a521d8
2 changed files with 48 additions and 0 deletions

View File

@ -15,6 +15,7 @@ pub mod pidfd;
pub mod seccomp;
pub mod socket;
pub mod sys_mknod;
pub mod sys_quotactl;
pub mod syscall;
pub mod tools;

47
src/sys_quotactl.rs Normal file
View File

@ -0,0 +1,47 @@
use failure::Error;
use nix::errno::Errno;
use crate::lxcseccomp::ProxyMessageBuffer;
use crate::syscall::SyscallStatus;
/*
* int quotactl(int cmd, const char *special, int id, caddr_t addr);
*
* `special` is a path to the mount point, so we need to be in the process' file system view
* `addr` will point to a datastructure, so we should read a reasonable amount (a 4k page?) of
* memory from there, but only if the sub command type makes use of it.
*
* Actually the libc crate contains most of the structures anyway!
*
* Cmd:
* QCMD(SubCmd, Type)
* Type: USRQUOTA | GRPQUOTA | PRJQUOTA (but we don't need to care)
* SubCmd:
* | name addr meaning|
* Q_QUOTAON path to quota file
* Q_QUOTAOFF ignored
* Q_GETQUOTA struct dqblk {} a page should be sufficient
* Q_GETNEXTQUOTA struct nextdqblk {} a page should be sufficient
* Q_SETQUOTA struct dqblk {} a page should be sufficient
* Q_SETQUOTA struct dqblk {} a page should be sufficient
* Q_SETQLIM -EOPNOTSUPP: not documented anymore
* Q_SETUSE -EOPNOTSUPP: not documented anymore
* Q_GETINFO struct dqinfo {}
* Q_SETINFO struct dqinfo {}
* Q_GETFMT [u8; 4]
* Q_SYNC ignored -EOPNOTSUPP if `special` is NULL!
* Q_GETSTATS struct dqstats {} -EOPNOTSUPP: obsolete, removed since 2.4.22!
*
* xfs stuff:
* Q_XQUOTAON unsigned int
* Q_XQUOTAOFF unsigned int
* ...
* (we don't actually have xfs containers atm...)
*/
pub async fn quotactl(msg: &ProxyMessageBuffer) -> Result<SyscallStatus, Error> {
let _cmd = msg.arg_int(0)?;
let _special = msg.arg_opt_c_string(1)?;
let _id = msg.arg_int(2)?;
let _addr = msg.arg_caddr_t(3)?;
Ok(Errno::ENOSYS.into())
}