vfs: check userland buffers before reading them.
[haiku.git] / src / tools / fs_shell / sem.cpp
blobb5193b281b41e5615d36545c5ccee19c31bafa3e
1 /*
2 * Copyright 2007, Ingo Weinhold, bonefish@cs.tu-berlin.de.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "compatibility.h"
8 #include <string.h>
10 #include <OS.h>
12 #include "fssh_errors.h"
13 #include "fssh_os.h"
16 static void
17 copy_sem_info(fssh_sem_info* info, const sem_info* systemInfo)
19 info->sem = systemInfo->sem;
20 info->team = systemInfo->team;
21 strcpy(info->name, systemInfo->name);
22 info->count = systemInfo->count;
23 info->latest_holder = systemInfo->latest_holder;
27 // #pragma mark -
30 fssh_sem_id
31 fssh_create_sem(int32_t count, const char *name)
33 return create_sem(count, name);
37 fssh_status_t
38 fssh_delete_sem(fssh_sem_id id)
40 return delete_sem(id);
44 fssh_status_t
45 fssh_acquire_sem(fssh_sem_id id)
47 return acquire_sem(id);
51 fssh_status_t
52 fssh_acquire_sem_etc(fssh_sem_id id, int32_t count, uint32_t flags,
53 fssh_bigtime_t timeout)
55 return acquire_sem_etc(id, count, flags, timeout);
59 fssh_status_t
60 fssh_release_sem(fssh_sem_id id)
62 return release_sem(id);
66 fssh_status_t
67 fssh_release_sem_etc(fssh_sem_id id, int32_t count, uint32_t flags)
69 return release_sem_etc(id, count, flags);
73 fssh_status_t
74 fssh_get_sem_count(fssh_sem_id id, int32_t *threadCount)
76 return get_sem_count(id, (int32*)threadCount);
80 fssh_status_t
81 fssh_set_sem_owner(fssh_sem_id id, fssh_team_id team)
83 // return set_sem_owner(id, team);
84 // The FS shell is the kernel and no other teams exist.
85 return FSSH_B_OK;
89 fssh_status_t
90 _fssh_get_sem_info(fssh_sem_id id, struct fssh_sem_info *info,
91 fssh_size_t infoSize)
93 sem_info systemInfo;
94 status_t result = get_sem_info(id, &systemInfo);
95 if (result != B_OK)
96 return result;
98 copy_sem_info(info, &systemInfo);
100 return FSSH_B_OK;
104 fssh_status_t
105 _fssh_get_next_sem_info(fssh_team_id team, int32_t *cookie,
106 struct fssh_sem_info *info, fssh_size_t infoSize)
108 sem_info systemInfo;
109 status_t result = get_next_sem_info(team, (int32*)cookie, &systemInfo);
110 if (result != B_OK)
111 return result;
113 copy_sem_info(info, &systemInfo);
115 return FSSH_B_OK;