1 2 #include "inc.h" 3 4 #include <sys/svrctl.h> 5 6 const char * 7 svrctl_name(unsigned long req) 8 { 9 10 switch (req) { 11 NAME(PMSETPARAM); 12 NAME(PMGETPARAM); 13 NAME(VFSGETPARAM); 14 NAME(VFSSETPARAM); 15 } 16 17 return NULL; 18 } 19 20 int 21 svrctl_arg(struct trace_proc * proc, unsigned long req, void * ptr, int dir) 22 { 23 struct sysgetenv *env; 24 25 switch (req) { 26 case PMSETPARAM: 27 case VFSSETPARAM: 28 if ((env = (struct sysgetenv *)ptr) == NULL) 29 return IF_OUT; 30 31 put_buf(proc, "key", PF_STRING, (vir_bytes)env->key, 32 env->keylen); 33 put_buf(proc, "value", PF_STRING, (vir_bytes)env->val, 34 env->vallen); 35 return IF_ALL; 36 37 case PMGETPARAM: 38 case VFSGETPARAM: 39 if ((env = (struct sysgetenv *)ptr) == NULL) 40 return IF_OUT | IF_IN; 41 42 /* 43 * So far this is the only IOCTL case where the output depends 44 * on one of the values in the input: if the given key is NULL, 45 * PM provides the entire system environment in return, which 46 * means we cannot just print a single string. We rely on PM 47 * not changing the key field, which (while true) is an 48 * assumption. With the current (simple) model we would have 49 * to save the provided key pointer somewhere otherwise. 50 */ 51 if (dir == IF_OUT) 52 put_buf(proc, "key", PF_STRING, (vir_bytes)env->key, 53 env->keylen); 54 else 55 put_buf(proc, "value", 56 (env->key != NULL) ? PF_STRING : 0, 57 (vir_bytes)env->val, env->vallen); 58 return IF_ALL; 59 60 default: 61 return 0; 62 } 63 } 64