diff options
author | Mans Rullgard <mans@mansr.com> | 2011-08-26 14:06:29 -0400 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2012-05-24 14:27:57 -0400 |
commit | 7a8bb98ca9653daf46374dbc37ad196bccfe0a02 (patch) | |
tree | 82dc6699fea21df6df204acfbc27417bcc4cad7a /arch/alpha | |
parent | 50744dee010657f0e0bd97e32651061109f1207a (diff) |
alpha: implement various OSF/1 stat syscalls
This implements OSF/1 versions of stat, lstat, fstat, statfs64,
and fstatfs64 syscalls.
Signed-off-by: Mans Rullgard <mans@mansr.com>
Signed-off-by: Matt Turner <mattst88@gmail.com>
Diffstat (limited to 'arch/alpha')
-rw-r--r-- | arch/alpha/include/asm/unistd.h | 6 | ||||
-rw-r--r-- | arch/alpha/kernel/osf_sys.c | 163 | ||||
-rw-r--r-- | arch/alpha/kernel/systbls.S | 10 |
3 files changed, 174 insertions, 5 deletions
diff --git a/arch/alpha/include/asm/unistd.h b/arch/alpha/include/asm/unistd.h index 2207fc61665d..d1f23b722df4 100644 --- a/arch/alpha/include/asm/unistd.h +++ b/arch/alpha/include/asm/unistd.h | |||
@@ -203,6 +203,12 @@ | |||
203 | #define __NR_osf_security 222 /* not implemented */ | 203 | #define __NR_osf_security 222 /* not implemented */ |
204 | #define __NR_osf_kloadcall 223 /* not implemented */ | 204 | #define __NR_osf_kloadcall 223 /* not implemented */ |
205 | 205 | ||
206 | #define __NR_osf_stat 224 | ||
207 | #define __NR_osf_lstat 225 | ||
208 | #define __NR_osf_fstat 226 | ||
209 | #define __NR_osf_statfs64 227 | ||
210 | #define __NR_osf_fstatfs64 228 | ||
211 | |||
206 | #define __NR_getpgid 233 | 212 | #define __NR_getpgid 233 |
207 | #define __NR_getsid 234 | 213 | #define __NR_getsid 234 |
208 | #define __NR_sigaltstack 235 | 214 | #define __NR_sigaltstack 235 |
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c index 9a81044a8947..98a103621af6 100644 --- a/arch/alpha/kernel/osf_sys.c +++ b/arch/alpha/kernel/osf_sys.c | |||
@@ -191,6 +191,39 @@ SYSCALL_DEFINE6(osf_mmap, unsigned long, addr, unsigned long, len, | |||
191 | return ret; | 191 | return ret; |
192 | } | 192 | } |
193 | 193 | ||
194 | struct osf_stat { | ||
195 | int st_dev; | ||
196 | int st_pad1; | ||
197 | unsigned st_mode; | ||
198 | unsigned short st_nlink; | ||
199 | short st_nlink_reserved; | ||
200 | unsigned st_uid; | ||
201 | unsigned st_gid; | ||
202 | int st_rdev; | ||
203 | int st_ldev; | ||
204 | long st_size; | ||
205 | int st_pad2; | ||
206 | int st_uatime; | ||
207 | int st_pad3; | ||
208 | int st_umtime; | ||
209 | int st_pad4; | ||
210 | int st_uctime; | ||
211 | int st_pad5; | ||
212 | int st_pad6; | ||
213 | unsigned st_flags; | ||
214 | unsigned st_gen; | ||
215 | long st_spare[4]; | ||
216 | unsigned st_ino; | ||
217 | int st_ino_reserved; | ||
218 | int st_atime; | ||
219 | int st_atime_reserved; | ||
220 | int st_mtime; | ||
221 | int st_mtime_reserved; | ||
222 | int st_ctime; | ||
223 | int st_ctime_reserved; | ||
224 | long st_blksize; | ||
225 | long st_blocks; | ||
226 | }; | ||
194 | 227 | ||
195 | /* | 228 | /* |
196 | * The OSF/1 statfs structure is much larger, but this should | 229 | * The OSF/1 statfs structure is much larger, but this should |
@@ -209,6 +242,60 @@ struct osf_statfs { | |||
209 | __kernel_fsid_t f_fsid; | 242 | __kernel_fsid_t f_fsid; |
210 | }; | 243 | }; |
211 | 244 | ||
245 | struct osf_statfs64 { | ||
246 | short f_type; | ||
247 | short f_flags; | ||
248 | int f_pad1; | ||
249 | int f_pad2; | ||
250 | int f_pad3; | ||
251 | int f_pad4; | ||
252 | int f_pad5; | ||
253 | int f_pad6; | ||
254 | int f_pad7; | ||
255 | __kernel_fsid_t f_fsid; | ||
256 | u_short f_namemax; | ||
257 | short f_reserved1; | ||
258 | int f_spare[8]; | ||
259 | char f_pad8[90]; | ||
260 | char f_pad9[90]; | ||
261 | long mount_info[10]; | ||
262 | u_long f_flags2; | ||
263 | long f_spare2[14]; | ||
264 | long f_fsize; | ||
265 | long f_bsize; | ||
266 | long f_blocks; | ||
267 | long f_bfree; | ||
268 | long f_bavail; | ||
269 | long f_files; | ||
270 | long f_ffree; | ||
271 | }; | ||
272 | |||
273 | static int | ||
274 | linux_to_osf_stat(struct kstat *lstat, struct osf_stat __user *osf_stat) | ||
275 | { | ||
276 | struct osf_stat tmp = { 0 }; | ||
277 | |||
278 | tmp.st_dev = lstat->dev; | ||
279 | tmp.st_mode = lstat->mode; | ||
280 | tmp.st_nlink = lstat->nlink; | ||
281 | tmp.st_uid = lstat->uid; | ||
282 | tmp.st_gid = lstat->gid; | ||
283 | tmp.st_rdev = lstat->rdev; | ||
284 | tmp.st_ldev = lstat->rdev; | ||
285 | tmp.st_size = lstat->size; | ||
286 | tmp.st_uatime = lstat->atime.tv_nsec / 1000; | ||
287 | tmp.st_umtime = lstat->mtime.tv_nsec / 1000; | ||
288 | tmp.st_uctime = lstat->ctime.tv_nsec / 1000; | ||
289 | tmp.st_ino = lstat->ino; | ||
290 | tmp.st_atime = lstat->atime.tv_sec; | ||
291 | tmp.st_mtime = lstat->mtime.tv_sec; | ||
292 | tmp.st_ctime = lstat->ctime.tv_sec; | ||
293 | tmp.st_blksize = lstat->blksize; | ||
294 | tmp.st_blocks = lstat->blocks; | ||
295 | |||
296 | return copy_to_user(osf_stat, &tmp, sizeof(tmp)) ? -EFAULT : 0; | ||
297 | } | ||
298 | |||
212 | static int | 299 | static int |
213 | linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_stat, | 300 | linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_stat, |
214 | unsigned long bufsiz) | 301 | unsigned long bufsiz) |
@@ -230,6 +317,26 @@ linux_to_osf_statfs(struct kstatfs *linux_stat, struct osf_statfs __user *osf_st | |||
230 | return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0; | 317 | return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0; |
231 | } | 318 | } |
232 | 319 | ||
320 | static int | ||
321 | linux_to_osf_statfs64(struct kstatfs *linux_stat, struct osf_statfs64 __user *osf_stat, | ||
322 | unsigned long bufsiz) | ||
323 | { | ||
324 | struct osf_statfs64 tmp_stat = { 0 }; | ||
325 | |||
326 | tmp_stat.f_type = linux_stat->f_type; | ||
327 | tmp_stat.f_fsize = linux_stat->f_frsize; | ||
328 | tmp_stat.f_bsize = linux_stat->f_bsize; | ||
329 | tmp_stat.f_blocks = linux_stat->f_blocks; | ||
330 | tmp_stat.f_bfree = linux_stat->f_bfree; | ||
331 | tmp_stat.f_bavail = linux_stat->f_bavail; | ||
332 | tmp_stat.f_files = linux_stat->f_files; | ||
333 | tmp_stat.f_ffree = linux_stat->f_ffree; | ||
334 | tmp_stat.f_fsid = linux_stat->f_fsid; | ||
335 | if (bufsiz > sizeof(tmp_stat)) | ||
336 | bufsiz = sizeof(tmp_stat); | ||
337 | return copy_to_user(osf_stat, &tmp_stat, bufsiz) ? -EFAULT : 0; | ||
338 | } | ||
339 | |||
233 | SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname, | 340 | SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname, |
234 | struct osf_statfs __user *, buffer, unsigned long, bufsiz) | 341 | struct osf_statfs __user *, buffer, unsigned long, bufsiz) |
235 | { | 342 | { |
@@ -240,6 +347,42 @@ SYSCALL_DEFINE3(osf_statfs, const char __user *, pathname, | |||
240 | return error; | 347 | return error; |
241 | } | 348 | } |
242 | 349 | ||
350 | SYSCALL_DEFINE2(osf_stat, char __user *, name, struct osf_stat __user *, buf) | ||
351 | { | ||
352 | struct kstat stat; | ||
353 | int error; | ||
354 | |||
355 | error = vfs_stat(name, &stat); | ||
356 | if (error) | ||
357 | return error; | ||
358 | |||
359 | return linux_to_osf_stat(&stat, buf); | ||
360 | } | ||
361 | |||
362 | SYSCALL_DEFINE2(osf_lstat, char __user *, name, struct osf_stat __user *, buf) | ||
363 | { | ||
364 | struct kstat stat; | ||
365 | int error; | ||
366 | |||
367 | error = vfs_lstat(name, &stat); | ||
368 | if (error) | ||
369 | return error; | ||
370 | |||
371 | return linux_to_osf_stat(&stat, buf); | ||
372 | } | ||
373 | |||
374 | SYSCALL_DEFINE2(osf_fstat, int, fd, struct osf_stat __user *, buf) | ||
375 | { | ||
376 | struct kstat stat; | ||
377 | int error; | ||
378 | |||
379 | error = vfs_fstat(fd, &stat); | ||
380 | if (error) | ||
381 | return error; | ||
382 | |||
383 | return linux_to_osf_stat(&stat, buf); | ||
384 | } | ||
385 | |||
243 | SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd, | 386 | SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd, |
244 | struct osf_statfs __user *, buffer, unsigned long, bufsiz) | 387 | struct osf_statfs __user *, buffer, unsigned long, bufsiz) |
245 | { | 388 | { |
@@ -250,6 +393,26 @@ SYSCALL_DEFINE3(osf_fstatfs, unsigned long, fd, | |||
250 | return error; | 393 | return error; |
251 | } | 394 | } |
252 | 395 | ||
396 | SYSCALL_DEFINE3(osf_statfs64, char __user *, pathname, | ||
397 | struct osf_statfs64 __user *, buffer, unsigned long, bufsiz) | ||
398 | { | ||
399 | struct kstatfs linux_stat; | ||
400 | int error = user_statfs(pathname, &linux_stat); | ||
401 | if (!error) | ||
402 | error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz); | ||
403 | return error; | ||
404 | } | ||
405 | |||
406 | SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd, | ||
407 | struct osf_statfs64 __user *, buffer, unsigned long, bufsiz) | ||
408 | { | ||
409 | struct kstatfs linux_stat; | ||
410 | int error = fd_statfs(fd, &linux_stat); | ||
411 | if (!error) | ||
412 | error = linux_to_osf_statfs64(&linux_stat, buffer, bufsiz); | ||
413 | return error; | ||
414 | } | ||
415 | |||
253 | /* | 416 | /* |
254 | * Uhh.. OSF/1 mount parameters aren't exactly obvious.. | 417 | * Uhh.. OSF/1 mount parameters aren't exactly obvious.. |
255 | * | 418 | * |
diff --git a/arch/alpha/kernel/systbls.S b/arch/alpha/kernel/systbls.S index e534e1c5bc11..87835235f114 100644 --- a/arch/alpha/kernel/systbls.S +++ b/arch/alpha/kernel/systbls.S | |||
@@ -241,11 +241,11 @@ sys_call_table: | |||
241 | .quad alpha_ni_syscall | 241 | .quad alpha_ni_syscall |
242 | .quad alpha_ni_syscall | 242 | .quad alpha_ni_syscall |
243 | .quad alpha_ni_syscall | 243 | .quad alpha_ni_syscall |
244 | .quad alpha_ni_syscall | 244 | .quad sys_osf_stat |
245 | .quad alpha_ni_syscall /* 225 */ | 245 | .quad sys_osf_lstat /* 225 */ |
246 | .quad alpha_ni_syscall | 246 | .quad sys_osf_fstat |
247 | .quad alpha_ni_syscall | 247 | .quad sys_osf_statfs64 |
248 | .quad alpha_ni_syscall | 248 | .quad sys_osf_fstatfs64 |
249 | .quad alpha_ni_syscall | 249 | .quad alpha_ni_syscall |
250 | .quad alpha_ni_syscall /* 230 */ | 250 | .quad alpha_ni_syscall /* 230 */ |
251 | .quad alpha_ni_syscall | 251 | .quad alpha_ni_syscall |