diff --git a/headers/os/kernel/OS.h b/headers/os/kernel/OS.h index 62ff358648..22c55a8461 100644 --- a/headers/os/kernel/OS.h +++ b/headers/os/kernel/OS.h @@ -247,6 +247,15 @@ typedef struct { char args[64]; uid_t uid; gid_t gid; + + /* Haiku R1 extensions */ + uid_t real_uid; + gid_t real_gid; + pid_t group_id; + pid_t session_id; + team_id parent; + char name[B_OS_NAME_LENGTH]; + bigtime_t start_time; } team_info; #define B_CURRENT_TEAM 0 diff --git a/headers/private/kernel/team.h b/headers/private/kernel/team.h index 1c389d9abb..af53f23a7e 100644 --- a/headers/private/kernel/team.h +++ b/headers/private/kernel/team.h @@ -80,8 +80,8 @@ pid_t _user_process_info(pid_t process, int32 which); pid_t _user_setpgid(pid_t process, pid_t group); pid_t _user_setsid(void); -status_t _user_get_team_info(team_id id, team_info *info); -status_t _user_get_next_team_info(int32 *cookie, team_info *info); +status_t _user_get_team_info(team_id id, team_info *info, size_t size); +status_t _user_get_next_team_info(int32 *cookie, team_info *info, size_t size); status_t _user_get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size); status_t _user_get_extended_team_info(team_id teamID, uint32 flags, diff --git a/headers/private/kernel/thread_types.h b/headers/private/kernel/thread_types.h index 0ac367b063..d6cd748a5f 100644 --- a/headers/private/kernel/thread_types.h +++ b/headers/private/kernel/thread_types.h @@ -275,6 +275,8 @@ struct Team : TeamThreadIteratorEntry, KernelReferenceable, struct team_debug_info debug_info; + bigtime_t start_time; + // protected by time_lock bigtime_t dead_threads_kernel_time; bigtime_t dead_threads_user_time; diff --git a/headers/private/system/syscalls.h b/headers/private/system/syscalls.h index 16ad7a2fe1..44b7f7d9a4 100644 --- a/headers/private/system/syscalls.h +++ b/headers/private/system/syscalls.h @@ -180,8 +180,10 @@ extern int64 _kern_restore_signal_frame( extern status_t _kern_get_thread_info(thread_id id, thread_info *info); extern status_t _kern_get_next_thread_info(team_id team, int32 *cookie, thread_info *info); -extern status_t _kern_get_team_info(team_id id, team_info *info); -extern status_t _kern_get_next_team_info(int32 *cookie, team_info *info); +extern status_t _kern_get_team_info(team_id id, team_info *info, + size_t size); +extern status_t _kern_get_next_team_info(int32 *cookie, team_info *info, + size_t size); extern status_t _kern_get_team_usage_info(team_id team, int32 who, team_usage_info *info, size_t size); extern status_t _kern_get_extended_team_info(team_id teamID, uint32 flags, diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp index ddf2b49422..2b248734f8 100644 --- a/src/system/kernel/team.cpp +++ b/src/system/kernel/team.cpp @@ -574,6 +574,8 @@ Team::Create(team_id id, const char* name, bool kernel) return NULL; } + team->start_time = system_time(); + // everything went fine return teamDeleter.Detach(); } @@ -2676,7 +2678,7 @@ wait_for_child(pid_t child, uint32 flags, siginfo_t& _info, static status_t fill_team_info(Team* team, team_info* info, size_t size) { - if (size != sizeof(team_info)) + if (size > sizeof(team_info)) return B_BAD_VALUE; // TODO: Set more informations for team_info @@ -2700,6 +2702,21 @@ fill_team_info(Team* team, team_info* info, size_t size) strlcpy(info->args, team->Args(), sizeof(info->args)); info->argc = 1; + if (size > offsetof(team_info, real_uid)) { + info->real_uid = team->real_uid; + info->real_gid = team->real_gid; + info->group_id = team->group_id; + info->session_id = team->session_id; + + if (team->parent != NULL) + info->parent = team->parent->id; + else + info->parent = -1; + + strlcpy(info->name, team->Name(), sizeof(info->name)); + info->start_time = team->start_time; + } + return B_OK; } @@ -4360,17 +4377,20 @@ _user_kill_team(team_id team) status_t -_user_get_team_info(team_id id, team_info* userInfo) +_user_get_team_info(team_id id, team_info* userInfo, size_t size) { status_t status; team_info info; + if (size > sizeof(team_info)) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(userInfo)) return B_BAD_ADDRESS; - status = _get_team_info(id, &info, sizeof(team_info)); + status = _get_team_info(id, &info, size); if (status == B_OK) { - if (user_memcpy(userInfo, &info, sizeof(team_info)) < B_OK) + if (user_memcpy(userInfo, &info, size) < B_OK) return B_BAD_ADDRESS; } @@ -4379,23 +4399,26 @@ _user_get_team_info(team_id id, team_info* userInfo) status_t -_user_get_next_team_info(int32* userCookie, team_info* userInfo) +_user_get_next_team_info(int32* userCookie, team_info* userInfo, size_t size) { status_t status; team_info info; int32 cookie; + if (size > sizeof(team_info)) + return B_BAD_VALUE; + if (!IS_USER_ADDRESS(userCookie) || !IS_USER_ADDRESS(userInfo) || user_memcpy(&cookie, userCookie, sizeof(int32)) < B_OK) return B_BAD_ADDRESS; - status = _get_next_team_info(&cookie, &info, sizeof(team_info)); + status = _get_next_team_info(&cookie, &info, size); if (status != B_OK) return status; if (user_memcpy(userCookie, &cookie, sizeof(int32)) < B_OK - || user_memcpy(userInfo, &info, sizeof(team_info)) < B_OK) + || user_memcpy(userInfo, &info, size) < B_OK) return B_BAD_ADDRESS; return status; diff --git a/src/system/libroot/os/team.c b/src/system/libroot/os/team.c index c3f54ac8ff..db6ca6b67d 100644 --- a/src/system/libroot/os/team.c +++ b/src/system/libroot/os/team.c @@ -35,19 +35,13 @@ kill_team(team_id team) status_t _get_team_info(team_id team, team_info *info, size_t size) { - if (info == NULL || size != sizeof(team_info)) - return B_BAD_VALUE; - - return _kern_get_team_info(team, info); + return _kern_get_team_info(team, info, size); } status_t _get_next_team_info(int32 *cookie, team_info *info, size_t size) { - if (info == NULL || size != sizeof(team_info)) - return B_BAD_VALUE; - - return _kern_get_next_team_info(cookie, info); + return _kern_get_next_team_info(cookie, info, size); }