Esempi rimasti indietro.
authorSimone Piccardi <piccardi@gnulinux.it>
Sun, 21 Aug 2011 19:38:21 +0000 (19:38 +0000)
committerSimone Piccardi <piccardi@gnulinux.it>
Sun, 21 Aug 2011 19:38:21 +0000 (19:38 +0000)
listati/cap-results.c [new file with mode: 0644]
listati/get_quota.c [new file with mode: 0644]
listati/set_block_quota.c [new file with mode: 0644]

diff --git a/listati/cap-results.c b/listati/cap-results.c
new file mode 100644 (file)
index 0000000..4b37d42
--- /dev/null
@@ -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 (file)
index 0000000..4685052
--- /dev/null
@@ -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 (file)
index 0000000..0ed7120
--- /dev/null
@@ -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;
+  }    
+}