* for Linux kernel.
*/
-cfs_task_t this_task =
+struct task_struct this_task =
{ /* umask */ 0,/* blocked*/0, /* pid */ 0, /* pgrp */ 0,
- /* uid,euid,suid,fsuid */ 0, 0, 0, 0,
+ /* uid,euid,suid,fsuid */ 0, 0, 0, 0,
/* gid_t gid,egid,sgid,fsgid */ 0, 0, 0, 0,
/* ngroups*/ 1, /*cgroups*/ 0, /*groups*/ 0,
/* group_info */ NULL,
};
-uid_t cfs_curproc_uid(void)
+uid_t current_uid(void)
{
return this_task.uid;
}
-gid_t cfs_curproc_gid(void)
+gid_t current_gid(void)
{
return this_task.gid;
}
-uid_t cfs_curproc_fsuid(void)
+uid_t current_fsuid(void)
{
return this_task.fsuid;
}
-gid_t cfs_curproc_fsgid(void)
+gid_t current_fsgid(void)
{
return this_task.fsgid;
}
-pid_t cfs_curproc_pid(void)
+pid_t current_pid(void)
{
- return cfs_current()->pid;
+ return current->pid;
}
-int cfs_curproc_groups_nr(void)
-{
- return this_task.ngroups;
-}
-
-void cfs_curproc_groups_dump(gid_t *array, int size)
-{
- LASSERT(size <= NGROUPS);
- size = min_t(int, size, this_task.ngroups);
- memcpy(array, this_task.groups, size * sizeof(__u32));
-}
-
-int cfs_curproc_is_in_groups(gid_t gid)
-{
- return in_group_p(gid);
-}
-
-mode_t cfs_curproc_umask(void)
+mode_t current_umask(void)
{
return this_task.umask;
}
-char *cfs_curproc_comm(void)
+char *current_comm(void)
{
return this_task.comm;
}
* task slot routiens
*/
-PTASK_SLOT
-alloc_task_slot()
+PTASK_SLOT alloc_task_slot()
{
- PTASK_SLOT task = NULL;
-
- if (cfs_win_task_manger.slab) {
- task = cfs_mem_cache_alloc(cfs_win_task_manger.slab, 0);
- } else {
- task = cfs_alloc(sizeof(TASK_SLOT), 0);
- }
-
- return task;
+ if (cfs_win_task_manger.slab)
+ return kmem_cache_alloc(cfs_win_task_manger.slab, 0);
+ else
+ return kmalloc(sizeof(TASK_SLOT), 0);
}
void
cfs_init_event(&task->Event, TRUE, FALSE);
}
-void
-cleanup_task_slot(PTASK_SLOT task)
+void cleanup_task_slot(PTASK_SLOT task)
{
- if (task->task.pid) {
- cfs_idr_remove(cfs_win_task_slot_idp, task->task.pid);
- }
+ if (task->task.pid)
+ cfs_idr_remove(cfs_win_task_slot_idp, task->task.pid);
- if (cfs_win_task_manger.slab) {
- cfs_mem_cache_free(cfs_win_task_manger.slab, task);
- } else {
- cfs_free(task);
- }
+ if (cfs_win_task_manger.slab)
+ kmem_cache_free(cfs_win_task_manger.slab, task);
+ else
+ kfree(task);
}
/*
IN BOOLEAN Create
)
{
- PLIST_ENTRY ListEntry = NULL;
+ PLIST_ENTRY ListEntry = NULL;
PTASK_SLOT TaskSlot = NULL;
spin_lock(&(cfs_win_task_manger.Lock));
/* initialize the spinlock protection */
spin_lock_init(&cfs_win_task_manger.Lock);
- /* create slab memory cache */
- cfs_win_task_manger.slab = cfs_mem_cache_create(
- "TSLT", sizeof(TASK_SLOT), 0, 0);
+ /* create slab memory cache */
+ cfs_win_task_manger.slab = kmem_cache_create("TSLT", sizeof(TASK_SLOT),
+ 0, 0, NULL);
/* intialize the list header */
InitializeListHead(&(cfs_win_task_manger.TaskList));
void
cleanup_task_manager()
{
- PLIST_ENTRY ListEntry = NULL;
+ PLIST_ENTRY ListEntry = NULL;
PTASK_SLOT TaskSlot = NULL;
/* remove ThreadNotifyRoutine: task_manager_notify */
spin_unlock(&cfs_win_task_manger.Lock);
- /* destroy the taskslot cache slab */
- cfs_mem_cache_destroy(cfs_win_task_manger.slab);
- memset(&cfs_win_task_manger, 0, sizeof(TASK_MAN));
+ /* destroy the taskslot cache slab */
+ kmem_cache_destroy(cfs_win_task_manger.slab);
+ memset(&cfs_win_task_manger, 0, sizeof(TASK_MAN));
}
*/
-cfs_task_t *
-cfs_current()
+struct task_struct *
+current
{
HANDLE Pid = PsGetCurrentProcessId();
HANDLE Tid = PsGetCurrentThreadId();
PETHREAD Tet = PsGetCurrentThread();
- PLIST_ENTRY ListEntry = NULL;
+ PLIST_ENTRY ListEntry = NULL;
PTASK_SLOT TaskSlot = NULL;
spin_lock(&(cfs_win_task_manger.Lock));
{
PTASK_SLOT Prev = NULL, Curr = NULL;
-
+
ListEntry = cfs_win_task_manger.TaskList.Flink;
while (ListEntry != (&(cfs_win_task_manger.TaskList))) {
void
cfs_pause(cfs_duration_t ticks)
{
- cfs_schedule_timeout_and_set_state(CFS_TASK_UNINTERRUPTIBLE, ticks);
+ schedule_timeout_and_set_state(CFS_TASK_UNINTERRUPTIBLE, ticks);
}
void
-cfs_schedule_timeout_and_set_state(cfs_task_state_t state, int64_t time)
+schedule_timeout_and_set_state(long state, int64_t time)
{
- cfs_task_t * task = cfs_current();
+ struct task_struct * task = current;
PTASK_SLOT slot = NULL;
if (!task) {
slot = CONTAINING_RECORD(task, TASK_SLOT, task);
cfs_assert(slot->Magic == TASKSLT_MAGIC);
- if (time == CFS_MAX_SCHEDULE_TIMEOUT) {
+ if (time == MAX_SCHEDULE_TIMEOUT) {
time = 0;
}
}
void
-cfs_schedule()
+schedule()
{
- cfs_schedule_timeout_and_set_state(CFS_TASK_UNINTERRUPTIBLE, 0);
+ schedule_timeout_and_set_state(CFS_TASK_UNINTERRUPTIBLE, 0);
}
int
wake_up_process(
- cfs_task_t * task
+ struct task_struct * task
)
{
PTASK_SLOT slot = NULL;
}
void
-sleep_on(cfs_waitq_t *waitq)
+sleep_on(wait_queue_head_t *waitq)
{
- cfs_waitlink_t link;
-
- cfs_waitlink_init(&link);
- cfs_waitq_add(waitq, &link);
- cfs_waitq_wait(&link, CFS_TASK_INTERRUPTIBLE);
- cfs_waitq_del(waitq, &link);
+ wait_queue_t link;
+
+ init_waitqueue_entry_current(&link);
+ add_wait_queue(waitq, &link);
+ waitq_wait(&link, TASK_INTERRUPTIBLE);
+ remove_wait_queue(waitq, &link);
}
-EXPORT_SYMBOL(cfs_curproc_uid);
-EXPORT_SYMBOL(cfs_curproc_pid);
-EXPORT_SYMBOL(cfs_curproc_gid);
-EXPORT_SYMBOL(cfs_curproc_fsuid);
-EXPORT_SYMBOL(cfs_curproc_fsgid);
-EXPORT_SYMBOL(cfs_curproc_umask);
-EXPORT_SYMBOL(cfs_curproc_comm);
-EXPORT_SYMBOL(cfs_curproc_groups_nr);
-EXPORT_SYMBOL(cfs_curproc_groups_dump);
-EXPORT_SYMBOL(cfs_curproc_is_in_groups);
+EXPORT_SYMBOL(current_uid);
+EXPORT_SYMBOL(current_pid);
+EXPORT_SYMBOL(current_gid);
+EXPORT_SYMBOL(current_fsuid);
+EXPORT_SYMBOL(current_fsgid);
+EXPORT_SYMBOL(current_umask);
+EXPORT_SYMBOL(current_comm);
EXPORT_SYMBOL(cfs_cap_raise);
EXPORT_SYMBOL(cfs_cap_lower);
EXPORT_SYMBOL(cfs_cap_raised);