Implememnt rctlblk_*
authorDavid Bartley <dtbartle@maltodextrin.csclub.uwaterloo.ca>
Tue, 9 Sep 2008 01:00:33 +0000 (01:00 +0000)
committerDavid Bartley <dtbartle@maltodextrin.csclub.uwaterloo.ca>
Tue, 9 Sep 2008 01:00:33 +0000 (01:00 +0000)
sysdeps/unix/sysv/solaris2/kopensolaris-gnu/Versions
sysdeps/unix/sysv/solaris2/kopensolaris-gnu/rctl.c
sysdeps/unix/sysv/solaris2/kopensolaris-gnu/sys/rctl.h

index daadacf..6ce9634 100644 (file)
@@ -44,7 +44,12 @@ libc {
     pset_setattr; putacct;
 
     # r
-    rctllist; resolvepath;
+    rctlblk_get_firing_time; rctlblk_get_global_action;
+    rctlblk_get_global_flags; rctlblk_get_local_action;
+    rctlblk_get_local_flags; rctlblk_get_privilege; rctlblk_get_recipient_pid;
+    rctlblk_get_value; rctlblk_get_enforced_value; rctlblk_set_local_action;
+    rctlblk_set_local_flags; rctlblk_set_privilege; rctlblk_set_value;
+    rctlblk_set_recipient_pid; rctlblk_size; rctllist; resolvepath;
 
     # s
     sendfilev; sendfilev64; setpflags; setppriv; setprojrctl; setrctl;
index bc67917..eb3b875 100644 (file)
 #include <inline-syscall.h>
 #include <syscallP.h>
 #include <sys/rctl.h>
+#include <sys/rctl_impl.h>
 
-/* Docs: http://docs.sun.com/app/docs/doc/816-5167/getrctl-2?a=view.  */
+/* Docs: http://docs.sun.com/app/docs/doc/816-5167/getrctl-2?a=view
+         http://docs.sun.com/app/docs/doc/816-5168/rctlblk-size-3c?a=view  */
 
 DECLARE_INLINE_SYSCALL (long, rctlsys, int code, const char *name, void *obuf,
     void *nbuf, size_t obufsz, int flags);
@@ -62,3 +64,109 @@ int setprojrctl (const char *name, rctlblk_t *blk, size_t size, int flags)
   return (int)INLINE_SYSCALL (rctlsys, 6, SYS_SUB_rctlsys_projset, name,
     NULL, blk, size, flags);
 }
+
+
+hrtime_t rctlblk_get_firing_time (rctlblk_t *rblk)
+{
+  return ((rctl_opaque_t *)rblk)->rcq_firing_time;
+}
+
+
+int rctlblk_get_global_action (rctlblk_t *rblk)
+{
+  /* Note: rcq_global_flagaction contains both flags and action.  */
+  return ((rctl_opaque_t *)rblk)->rcq_global_flagaction &
+    ~RCTL_GLOBAL_ACTION_MASK;
+}
+
+
+int rctlblk_get_global_flags (rctlblk_t *rblk)
+{
+  /* Note: rcq_global_flagaction contains both flags and action.  */
+  return ((rctl_opaque_t *)rblk)->rcq_global_flagaction &
+    RCTL_GLOBAL_ACTION_MASK;
+}
+
+
+int rctlblk_get_local_action (rctlblk_t *rblk, int *signalp)
+{
+  /* Note: rcq_local_flagaction contains both flags and action.  */
+  return ((rctl_opaque_t *)rblk)->rcq_local_flagaction &
+    ~RCTL_LOCAL_ACTION_MASK;
+}
+
+
+int rctlblk_get_local_flags (rctlblk_t *rblk)
+{
+  /* Note: rcq_local_flagaction contains both flags and action.  */
+  return ((rctl_opaque_t *)rblk)->rcq_local_flagaction &
+    RCTL_LOCAL_ACTION_MASK;
+}
+
+
+rctl_priv_t rctlblk_get_privilege (rctlblk_t *rblk)
+{
+  return ((rctl_opaque_t *)rblk)->rcq_privilege;
+}
+
+
+id_t rctlblk_get_recipient_pid (rctlblk_t *rblk)
+{
+  return ((rctl_opaque_t *)rblk)->rcq_local_recipient_pid;
+}
+
+
+rctl_qty_t rctlblk_get_value (rctlblk_t *rblk)
+{
+  return ((rctl_opaque_t *)rblk)->rcq_value;
+}
+
+
+rctl_qty_t rctlblk_get_enforced_value (rctlblk_t *rblk)
+{
+  return ((rctl_opaque_t *)rblk)->rcq_enforced_value;
+}
+
+
+void rctlblk_set_local_action (rctlblk_t *rblk, unsigned int action,
+     int signal)
+{
+  /* Note: rcq_local_flagaction contains both flags and action.  */
+  rctl_opaque_t *_rblk = (rctl_opaque_t *)rblk;
+  _rblk->rcq_local_signal = signal;
+  _rblk->rcq_local_flagaction = (_rblk->rcq_local_flagaction &
+      RCTL_LOCAL_ACTION_MASK) | action;
+}
+
+
+void rctlblk_set_local_flags (rctlblk_t *rblk, int flags)
+{
+  /* Note: rcq_local_flagaction contains both flags and action.  */
+  rctl_opaque_t *_rblk = (rctl_opaque_t *)rblk;
+  _rblk->rcq_local_flagaction = (_rblk->rcq_local_flagaction &
+      ~RCTL_LOCAL_ACTION_MASK) | flags;
+}
+
+
+void rctlblk_set_privilege (rctlblk_t *rblk, rctl_priv_t privilege)
+{
+  ((rctl_opaque_t *)rblk)->rcq_privilege = privilege;
+}
+
+
+void rctlblk_set_value (rctlblk_t *rblk, rctl_qty_t value)
+{
+  ((rctl_opaque_t *)rblk)->rcq_value = value;
+}
+
+
+void  rctlblk_set_recipient_pid (rctlblk_t *rblk, id_t pid)
+{
+  ((rctl_opaque_t *)rblk)->rcq_local_recipient_pid = pid;
+}
+
+
+size_t rctlblk_size (void)
+{
+  return sizeof (rctl_opaque_t);
+}
index 149fdc9..4ae9fd7 100644 (file)
@@ -26,6 +26,33 @@ typedef unsigned long long rctl_qty_t;
 typedef int rctl_priv_t;
 typedef struct rctlblk rctlblk_t;
 
+#define RCTL_LOCAL_NOACTION    0x00000000
+#define RCTL_LOCAL_SIGNAL      0x00000001
+#define RCTL_LOCAL_DENY                0x00000002
+#define RCTL_LOCAL_MAXIMAL     0x80000000
+#define RCTL_LOCAL_PROJDB      0x40000000
+#define RCTL_LOCAL_ACTION_MASK 0xffff0000
+#define RCTL_LOCAL_MASK                0xc0000003
+
+#define RCTL_GLOBAL_NOACTION           0x00000000
+#define RCTL_GLOBAL_SYSLOG             0x00000001
+#define RCTL_GLOBAL_NOBASIC            0x80000000
+#define RCTL_GLOBAL_LOWERABLE          0x40000000
+#define RCTL_GLOBAL_DENY_ALWAYS                0x20000000
+#define RCTL_GLOBAL_DENY_NEVER         0x10000000
+#define RCTL_GLOBAL_FILE_SIZE          0x08000000
+#define RCTL_GLOBAL_CPU_TIME           0x04000000
+#define RCTL_GLOBAL_SIGNAL_NEVER       0x02000000
+#define RCTL_GLOBAL_NOLOCALACTION      RCTL_GLOBAL_SIGNAL_NEVER
+#define RCTL_GLOBAL_INFINITE           0x01000000
+#define RCTL_GLOBAL_UNOBSERVABLE       0x00800000
+#define RCTL_GLOBAL_SYSLOG_NEVER       0x00080000
+#define RCTL_GLOBAL_BYTES              0x00400000
+#define RCTL_GLOBAL_SECONDS            0x00200000
+#define RCTL_GLOBAL_COUNT              0x00100000
+#define RCTL_GLOBAL_ACTION_MASK                0xffff0000
+#define RCTL_GLOBAL_MASK               0xfff80001
+
 __BEGIN_DECLS
 
 int setrctl (const char *controlname, rctlblk_t *old_blk, rctlblk_t *new_blk,