From: Simone Piccardi Date: Sun, 21 Aug 2011 19:38:21 +0000 (+0000) Subject: Esempi rimasti indietro. X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=commitdiff_plain;h=a26655598e1260eeb528ded46724e977f3aafee0;p=gapil.git Esempi rimasti indietro. --- diff --git a/listati/cap-results.c b/listati/cap-results.c new file mode 100644 index 0000000..4b37d42 --- /dev/null +++ b/listati/cap-results.c @@ -0,0 +1,4 @@ +new_perm = ( orig_inh & file_inh ) | ( file_perm & bound_set) ; +new_inh = orig_inh ; +new_eff = file_eff ? new_perm : 0 ; +new_bound_set = bound_set ; diff --git a/listati/get_quota.c b/listati/get_quota.c new file mode 100644 index 0000000..4685052 --- /dev/null +++ b/listati/get_quota.c @@ -0,0 +1,17 @@ +PyObject * get_quota(int who, int id, const char *dev) +{ + struct dqblk dq; + + if (!quotactl(QCMD(Q_GETQUOTA,who), dev, id, (caddr_t) &dq)) { + return Py_BuildValue("({s:K,s:(KK),s:K},{s:K,s:(KK),s:K})", + "used", dq.dqb_curspace, + "quota", dq.dqb_bsoftlimit, dq.dqb_bhardlimit, + "grace", dq.dqb_btime, + "used", dq.dqb_curinodes, + "quota", dq.dqb_isoftlimit, dq.dqb_ihardlimit, + "grace", dq.dqb_itime ); + } else { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } +} diff --git a/listati/set_block_quota.c b/listati/set_block_quota.c new file mode 100644 index 0000000..0ed7120 --- /dev/null +++ b/listati/set_block_quota.c @@ -0,0 +1,15 @@ +PyObject *set_block_quota(int who, int id, const char *dev, int soft, int hard) +{ + struct dqblk dq; + + dq.dqb_bsoftlimit = soft; + dq.dqb_bhardlimit = hard; + dq.dqb_valid = QIF_BLIMITS; + + if (!quotactl(QCMD(Q_SETQUOTA,who), dev, id, (caddr_t) &dq)) { + Py_RETURN_NONE; + } else { + PyErr_SetFromErrno(PyExc_OSError); + return NULL; + } +}