X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=libcfs%2Flibcfs%2Fwinnt%2Fwinnt-curproc.c;h=63478273f74614869aa3cd15c23ec8d6b0a3f15a;hb=a66e12d6ede2afda3bb7a5b1f22b8c17c1176584;hp=68d17403965d6cf2443199d0cbd6771b74f0abd4;hpb=9fb46705ae86aa2c0ac29427f0ff24f923560eb7;p=fs%2Flustre-release.git diff --git a/libcfs/libcfs/winnt/winnt-curproc.c b/libcfs/libcfs/winnt/winnt-curproc.c index 68d1740..6347827 100644 --- a/libcfs/libcfs/winnt/winnt-curproc.c +++ b/libcfs/libcfs/winnt/winnt-curproc.c @@ -26,6 +26,8 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -45,9 +47,9 @@ * 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, @@ -56,55 +58,40 @@ cfs_task_t this_task = /* journal_info */ NULL }; +struct user_namespace init_user_ns __read_mostly; +EXPORT_SYMBOL(init_user_ns); -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) -{ - return cfs_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) +pid_t current_pid(void) { - return in_group_p(gid); + return current->pid; } -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; } @@ -153,18 +140,12 @@ struct idr_context * cfs_win_task_slot_idp = NULL; * 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 @@ -176,18 +157,15 @@ init_task_slot(PTASK_SLOT task) 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); } /* @@ -201,7 +179,7 @@ task_manager_notify( IN BOOLEAN Create ) { - PLIST_ENTRY ListEntry = NULL; + PLIST_ENTRY ListEntry = NULL; PTASK_SLOT TaskSlot = NULL; spin_lock(&(cfs_win_task_manger.Lock)); @@ -241,9 +219,9 @@ init_task_manager() /* 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)); @@ -272,7 +250,7 @@ init_task_manager() void cleanup_task_manager() { - PLIST_ENTRY ListEntry = NULL; + PLIST_ENTRY ListEntry = NULL; PTASK_SLOT TaskSlot = NULL; /* remove ThreadNotifyRoutine: task_manager_notify */ @@ -298,9 +276,9 @@ cleanup_task_manager() 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)); } @@ -309,14 +287,14 @@ cleanup_task_manager() */ -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)); @@ -391,7 +369,7 @@ cfs_current() { PTASK_SLOT Prev = NULL, Curr = NULL; - + ListEntry = cfs_win_task_manger.TaskList.Flink; while (ListEntry != (&(cfs_win_task_manger.TaskList))) { @@ -429,13 +407,13 @@ errorout: 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) { @@ -446,7 +424,7 @@ cfs_schedule_timeout_and_set_state(cfs_task_state_t state, int64_t time) 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; } @@ -454,14 +432,14 @@ cfs_schedule_timeout_and_set_state(cfs_task_state_t state, int64_t time) } 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; @@ -480,26 +458,23 @@ wake_up_process( } 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);