Hello All,
I developed 3 new system calls for linux. Have a look to them (attached
there is also the little source), and let me know if someone is
interested in
them.
The system calls are:
gettask(TaskName) This call returns the number of running
"TaskName"
processes on the system
getfirsttaskid(TaskName) This call returns the first PID of
"TaskName"
getnexttaskid(TaskName) This call return the next PID of
"TaskName"
I tested this calls on my Linux box (2.0.33): if someone is interested,
I
can insert them in the last kernel release, and give you a diff file.
Please reply me at cpizzi@bigfoot.com. I cannot have this mailing list
attached to my mail account.
Thanks and regards,
Cesare Pizzi
--------------74BBEADAFC2A459032BEF602
Content-Type: text/plain; charset=us-ascii; name="task.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="task.c"
/*
*
* Version 0.5.0 of a couple of stupid system calls to get some information
* about the tasks running on the system.
* Author: Cesare Pizzi (cpizzi@bigfoot.com)
*
*/
#include <linux/sched.h>
/*
* Retruns the number of "cmd" processes running on the system
*/
asmlinkage int sys_gettask(const char *cmd)
{
int i;
int count = 0;
int error;
/* Temporary pointer for the parameter */
char *tmp;
if ((error = getname(cmd,&tmp)) != 0) {
return(error);
}
for(i=0; *(task+i) != NULL; i++) {
/* Check if the task is the same wanted by the caller */
if ((strcmp(tmp,task[i]->comm)) == 0) {
count++;
}
}
putname(tmp);
return(count);
}
/*
* Retruns the PID of the first process pointed out by the parameter.
* Use the global variable task_pos
*/
static long task_pos = 0;
asmlinkage pid_t sys_getfirsttaskid(const char *cmd)
{
char *tmp;
int error;
/* Reset the position in the task structure */
task_pos = 0;
if ((error = getname(cmd,&tmp)) != 0) {
return(error);
}
for(; *(task+task_pos) != NULL; task_pos++) {
/* Check if the task is the same wanted by the caller */
if ((strcmp(tmp,task[task_pos]->comm)) == 0) {
/* PID catched */
return(task[task_pos]->pid);
}
}
putname(tmp);
return 0;
}
/*
* Retruns the PID of the next process pointed out by the parameter.
* Use the global variable task_pos
*/
asmlinkage pid_t sys_getnexttaskid(const char *cmd)
{
char *tmp;
int error;
int number;
/* Skip the previuos occurrence */
task_pos++;
/*
* Check for the position in task array: if the current position
* is greater than the last entry, skip the search
*/
for(number=0; *(task+number) != NULL; number++);
number--;
if (task_pos > number) {
return(0);
}
if ((error = getname(cmd,&tmp)) != 0) {
return(error);
}
for(; *(task+task_pos) != NULL; task_pos++) {
/* Check if the task is the same wanted by the caller */
if ((strcmp(tmp,task[task_pos]->comm)) == 0) {
/* PID catched */
return(task[task_pos]->pid);
}
}
putname(tmp);
return 0;
}
--------------74BBEADAFC2A459032BEF602--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu