get rid of NR_OPEN and introduce a sysctl_nr_open
[pv_ops_mirror.git] / arch / sparc64 / solaris / fs.c
blob9311bfe4f2f7e98cf6940782e26cabbbc5b4fd0f
1 /* $Id: fs.c,v 1.27 2002/02/08 03:57:14 davem Exp $
2 * fs.c: fs related syscall emulation for Solaris
4 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
6 * 1999-08-19 Implemented solaris F_FREESP (truncate)
7 * fcntl, by Jason Rappleye (rappleye@ccr.buffalo.edu)
8 */
10 #include <linux/types.h>
11 #include <linux/sched.h>
12 #include <linux/slab.h>
13 #include <linux/capability.h>
14 #include <linux/fs.h>
15 #include <linux/namei.h>
16 #include <linux/mm.h>
17 #include <linux/file.h>
18 #include <linux/stat.h>
19 #include <linux/smp_lock.h>
20 #include <linux/limits.h>
21 #include <linux/resource.h>
22 #include <linux/quotaops.h>
23 #include <linux/mount.h>
24 #include <linux/vfs.h>
26 #include <asm/uaccess.h>
27 #include <asm/string.h>
28 #include <asm/ptrace.h>
30 #include "conv.h"
32 #define R3_VERSION 1
33 #define R4_VERSION 2
35 typedef struct {
36 s32 tv_sec;
37 s32 tv_nsec;
38 } timestruct_t;
40 struct sol_stat {
41 u32 st_dev;
42 s32 st_pad1[3]; /* network id */
43 u32 st_ino;
44 u32 st_mode;
45 u32 st_nlink;
46 u32 st_uid;
47 u32 st_gid;
48 u32 st_rdev;
49 s32 st_pad2[2];
50 s32 st_size;
51 s32 st_pad3; /* st_size, off_t expansion */
52 timestruct_t st_atime;
53 timestruct_t st_mtime;
54 timestruct_t st_ctime;
55 s32 st_blksize;
56 s32 st_blocks;
57 char st_fstype[16];
58 s32 st_pad4[8]; /* expansion area */
61 struct sol_stat64 {
62 u32 st_dev;
63 s32 st_pad1[3]; /* network id */
64 u64 st_ino;
65 u32 st_mode;
66 u32 st_nlink;
67 u32 st_uid;
68 u32 st_gid;
69 u32 st_rdev;
70 s32 st_pad2[2];
71 s64 st_size;
72 timestruct_t st_atime;
73 timestruct_t st_mtime;
74 timestruct_t st_ctime;
75 s64 st_blksize;
76 s32 st_blocks;
77 char st_fstype[16];
78 s32 st_pad4[4]; /* expansion area */
81 #define UFSMAGIC (((unsigned)'u'<<24)||((unsigned)'f'<<16)||((unsigned)'s'<<8))
83 static inline int putstat(struct sol_stat __user *ubuf, struct kstat *kbuf)
85 u32 ino;
87 if (kbuf->size > MAX_NON_LFS ||
88 !sysv_valid_dev(kbuf->dev) ||
89 !sysv_valid_dev(kbuf->rdev))
90 return -EOVERFLOW;
91 ino = kbuf->ino;
92 if (sizeof(ino) < sizeof(kbuf->ino) && ino != kbuf->ino)
93 return -EOVERFLOW;
94 if (put_user (sysv_encode_dev(kbuf->dev), &ubuf->st_dev) ||
95 __put_user (ino, &ubuf->st_ino) ||
96 __put_user (kbuf->mode, &ubuf->st_mode) ||
97 __put_user (kbuf->nlink, &ubuf->st_nlink) ||
98 __put_user (kbuf->uid, &ubuf->st_uid) ||
99 __put_user (kbuf->gid, &ubuf->st_gid) ||
100 __put_user (sysv_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
101 __put_user (kbuf->size, &ubuf->st_size) ||
102 __put_user (kbuf->atime.tv_sec, &ubuf->st_atime.tv_sec) ||
103 __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime.tv_nsec) ||
104 __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime.tv_sec) ||
105 __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime.tv_nsec) ||
106 __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime.tv_sec) ||
107 __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime.tv_nsec) ||
108 __put_user (kbuf->blksize, &ubuf->st_blksize) ||
109 __put_user (kbuf->blocks, &ubuf->st_blocks) ||
110 __put_user (UFSMAGIC, (unsigned __user *)ubuf->st_fstype))
111 return -EFAULT;
112 return 0;
115 static inline int putstat64(struct sol_stat64 __user *ubuf, struct kstat *kbuf)
117 if (!sysv_valid_dev(kbuf->dev) || !sysv_valid_dev(kbuf->rdev))
118 return -EOVERFLOW;
119 if (put_user (sysv_encode_dev(kbuf->dev), &ubuf->st_dev) ||
120 __put_user (kbuf->ino, &ubuf->st_ino) ||
121 __put_user (kbuf->mode, &ubuf->st_mode) ||
122 __put_user (kbuf->nlink, &ubuf->st_nlink) ||
123 __put_user (kbuf->uid, &ubuf->st_uid) ||
124 __put_user (kbuf->gid, &ubuf->st_gid) ||
125 __put_user (sysv_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
126 __put_user (kbuf->size, &ubuf->st_size) ||
127 __put_user (kbuf->atime.tv_sec, &ubuf->st_atime.tv_sec) ||
128 __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime.tv_nsec) ||
129 __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime.tv_sec) ||
130 __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime.tv_nsec) ||
131 __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime.tv_sec) ||
132 __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime.tv_nsec) ||
133 __put_user (kbuf->blksize, &ubuf->st_blksize) ||
134 __put_user (kbuf->blocks, &ubuf->st_blocks) ||
135 __put_user (UFSMAGIC, (unsigned __user *)ubuf->st_fstype))
136 return -EFAULT;
137 return 0;
140 asmlinkage int solaris_stat(u32 filename, u32 statbuf)
142 struct kstat s;
143 int ret = vfs_stat(A(filename), &s);
144 if (!ret)
145 return putstat(A(statbuf), &s);
146 return ret;
149 asmlinkage int solaris_xstat(int vers, u32 filename, u32 statbuf)
151 /* Solaris doesn't bother with looking at vers, so we do neither */
152 return solaris_stat(filename, statbuf);
155 asmlinkage int solaris_stat64(u32 filename, u32 statbuf)
157 struct kstat s;
158 int ret = vfs_stat(A(filename), &s);
159 if (!ret)
160 return putstat64(A(statbuf), &s);
161 return ret;
164 asmlinkage int solaris_lstat(u32 filename, u32 statbuf)
166 struct kstat s;
167 int ret = vfs_lstat(A(filename), &s);
168 if (!ret)
169 return putstat(A(statbuf), &s);
170 return ret;
173 asmlinkage int solaris_lxstat(int vers, u32 filename, u32 statbuf)
175 return solaris_lstat(filename, statbuf);
178 asmlinkage int solaris_lstat64(u32 filename, u32 statbuf)
180 struct kstat s;
181 int ret = vfs_lstat(A(filename), &s);
182 if (!ret)
183 return putstat64(A(statbuf), &s);
184 return ret;
187 asmlinkage int solaris_fstat(unsigned int fd, u32 statbuf)
189 struct kstat s;
190 int ret = vfs_fstat(fd, &s);
191 if (!ret)
192 return putstat(A(statbuf), &s);
193 return ret;
196 asmlinkage int solaris_fxstat(int vers, u32 fd, u32 statbuf)
198 return solaris_fstat(fd, statbuf);
201 asmlinkage int solaris_fstat64(unsigned int fd, u32 statbuf)
203 struct kstat s;
204 int ret = vfs_fstat(fd, &s);
205 if (!ret)
206 return putstat64(A(statbuf), &s);
207 return ret;
210 asmlinkage int solaris_mknod(u32 path, u32 mode, s32 dev)
212 int (*sys_mknod)(const char __user *,int,unsigned) =
213 (int (*)(const char __user *,int,unsigned))SYS(mknod);
214 int major = sysv_major(dev);
215 int minor = sysv_minor(dev);
217 /* minor is guaranteed to be OK for MKDEV, major might be not */
218 if (major > 0xfff)
219 return -EINVAL;
220 return sys_mknod(A(path), mode, new_encode_dev(MKDEV(major,minor)));
223 asmlinkage int solaris_xmknod(int vers, u32 path, u32 mode, s32 dev)
225 return solaris_mknod(path, mode, dev);
228 asmlinkage int solaris_getdents64(unsigned int fd, void __user *dirent, unsigned int count)
230 int (*sys_getdents)(unsigned int, void __user *, unsigned int) =
231 (int (*)(unsigned int, void __user *, unsigned int))SYS(getdents);
233 return sys_getdents(fd, dirent, count);
236 /* This statfs thingie probably will go in the near future, but... */
238 struct sol_statfs {
239 short f_type;
240 s32 f_bsize;
241 s32 f_frsize;
242 s32 f_blocks;
243 s32 f_bfree;
244 u32 f_files;
245 u32 f_ffree;
246 char f_fname[6];
247 char f_fpack[6];
250 asmlinkage int solaris_statfs(u32 path, u32 buf, int len, int fstype)
252 int ret;
253 struct statfs s;
254 mm_segment_t old_fs = get_fs();
255 int (*sys_statfs)(const char __user *,struct statfs __user *) =
256 (int (*)(const char __user *,struct statfs __user *))SYS(statfs);
257 struct sol_statfs __user *ss = A(buf);
259 if (len != sizeof(struct sol_statfs)) return -EINVAL;
260 if (!fstype) {
261 /* FIXME: mixing userland and kernel pointers */
262 set_fs (KERNEL_DS);
263 ret = sys_statfs(A(path), &s);
264 set_fs (old_fs);
265 if (!ret) {
266 if (put_user (s.f_type, &ss->f_type) ||
267 __put_user (s.f_bsize, &ss->f_bsize) ||
268 __put_user (0, &ss->f_frsize) ||
269 __put_user (s.f_blocks, &ss->f_blocks) ||
270 __put_user (s.f_bfree, &ss->f_bfree) ||
271 __put_user (s.f_files, &ss->f_files) ||
272 __put_user (s.f_ffree, &ss->f_ffree) ||
273 __clear_user (&ss->f_fname, 12))
274 return -EFAULT;
276 return ret;
278 /* Linux can't stat unmounted filesystems so we
279 * simply lie and claim 100MB of 1GB is free. Sorry.
281 if (put_user (fstype, &ss->f_type) ||
282 __put_user (1024, &ss->f_bsize) ||
283 __put_user (0, &ss->f_frsize) ||
284 __put_user (1024*1024, &ss->f_blocks) ||
285 __put_user (100*1024, &ss->f_bfree) ||
286 __put_user (60000, &ss->f_files) ||
287 __put_user (50000, &ss->f_ffree) ||
288 __clear_user (&ss->f_fname, 12))
289 return -EFAULT;
290 return 0;
293 asmlinkage int solaris_fstatfs(u32 fd, u32 buf, int len, int fstype)
295 int ret;
296 struct statfs s;
297 mm_segment_t old_fs = get_fs();
298 int (*sys_fstatfs)(unsigned,struct statfs __user *) =
299 (int (*)(unsigned,struct statfs __user *))SYS(fstatfs);
300 struct sol_statfs __user *ss = A(buf);
302 if (len != sizeof(struct sol_statfs)) return -EINVAL;
303 if (!fstype) {
304 set_fs (KERNEL_DS);
305 ret = sys_fstatfs(fd, &s);
306 set_fs (old_fs);
307 if (!ret) {
308 if (put_user (s.f_type, &ss->f_type) ||
309 __put_user (s.f_bsize, &ss->f_bsize) ||
310 __put_user (0, &ss->f_frsize) ||
311 __put_user (s.f_blocks, &ss->f_blocks) ||
312 __put_user (s.f_bfree, &ss->f_bfree) ||
313 __put_user (s.f_files, &ss->f_files) ||
314 __put_user (s.f_ffree, &ss->f_ffree) ||
315 __clear_user (&ss->f_fname, 12))
316 return -EFAULT;
318 return ret;
320 /* Otherwise fstatfs is the same as statfs */
321 return solaris_statfs(0, buf, len, fstype);
324 struct sol_statvfs {
325 u32 f_bsize;
326 u32 f_frsize;
327 u32 f_blocks;
328 u32 f_bfree;
329 u32 f_bavail;
330 u32 f_files;
331 u32 f_ffree;
332 u32 f_favail;
333 u32 f_fsid;
334 char f_basetype[16];
335 u32 f_flag;
336 u32 f_namemax;
337 char f_fstr[32];
338 u32 f_filler[16];
341 struct sol_statvfs64 {
342 u32 f_bsize;
343 u32 f_frsize;
344 u64 f_blocks;
345 u64 f_bfree;
346 u64 f_bavail;
347 u64 f_files;
348 u64 f_ffree;
349 u64 f_favail;
350 u32 f_fsid;
351 char f_basetype[16];
352 u32 f_flag;
353 u32 f_namemax;
354 char f_fstr[32];
355 u32 f_filler[16];
358 static int report_statvfs(struct vfsmount *mnt, struct inode *inode, u32 buf)
360 struct kstatfs s;
361 int error;
362 struct sol_statvfs __user *ss = A(buf);
364 error = vfs_statfs(mnt->mnt_root, &s);
365 if (!error) {
366 const char *p = mnt->mnt_sb->s_type->name;
367 int i = 0;
368 int j = strlen (p);
370 if (j > 15) j = 15;
371 if (IS_RDONLY(inode)) i = 1;
372 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
373 if (!sysv_valid_dev(inode->i_sb->s_dev))
374 return -EOVERFLOW;
375 if (put_user (s.f_bsize, &ss->f_bsize) ||
376 __put_user (0, &ss->f_frsize) ||
377 __put_user (s.f_blocks, &ss->f_blocks) ||
378 __put_user (s.f_bfree, &ss->f_bfree) ||
379 __put_user (s.f_bavail, &ss->f_bavail) ||
380 __put_user (s.f_files, &ss->f_files) ||
381 __put_user (s.f_ffree, &ss->f_ffree) ||
382 __put_user (s.f_ffree, &ss->f_favail) ||
383 __put_user (sysv_encode_dev(inode->i_sb->s_dev), &ss->f_fsid) ||
384 __copy_to_user (ss->f_basetype,p,j) ||
385 __put_user (0, (char __user *)&ss->f_basetype[j]) ||
386 __put_user (s.f_namelen, &ss->f_namemax) ||
387 __put_user (i, &ss->f_flag) ||
388 __clear_user (&ss->f_fstr, 32))
389 return -EFAULT;
391 return error;
394 static int report_statvfs64(struct vfsmount *mnt, struct inode *inode, u32 buf)
396 struct kstatfs s;
397 int error;
398 struct sol_statvfs64 __user *ss = A(buf);
400 error = vfs_statfs(mnt->mnt_root, &s);
401 if (!error) {
402 const char *p = mnt->mnt_sb->s_type->name;
403 int i = 0;
404 int j = strlen (p);
406 if (j > 15) j = 15;
407 if (IS_RDONLY(inode)) i = 1;
408 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
409 if (!sysv_valid_dev(inode->i_sb->s_dev))
410 return -EOVERFLOW;
411 if (put_user (s.f_bsize, &ss->f_bsize) ||
412 __put_user (0, &ss->f_frsize) ||
413 __put_user (s.f_blocks, &ss->f_blocks) ||
414 __put_user (s.f_bfree, &ss->f_bfree) ||
415 __put_user (s.f_bavail, &ss->f_bavail) ||
416 __put_user (s.f_files, &ss->f_files) ||
417 __put_user (s.f_ffree, &ss->f_ffree) ||
418 __put_user (s.f_ffree, &ss->f_favail) ||
419 __put_user (sysv_encode_dev(inode->i_sb->s_dev), &ss->f_fsid) ||
420 __copy_to_user (ss->f_basetype,p,j) ||
421 __put_user (0, (char __user *)&ss->f_basetype[j]) ||
422 __put_user (s.f_namelen, &ss->f_namemax) ||
423 __put_user (i, &ss->f_flag) ||
424 __clear_user (&ss->f_fstr, 32))
425 return -EFAULT;
427 return error;
430 asmlinkage int solaris_statvfs(u32 path, u32 buf)
432 struct nameidata nd;
433 int error;
435 error = user_path_walk(A(path),&nd);
436 if (!error) {
437 struct inode * inode = nd.dentry->d_inode;
438 error = report_statvfs(nd.mnt, inode, buf);
439 path_release(&nd);
441 return error;
444 asmlinkage int solaris_fstatvfs(unsigned int fd, u32 buf)
446 struct file * file;
447 int error;
449 error = -EBADF;
450 file = fget(fd);
451 if (file) {
452 error = report_statvfs(file->f_path.mnt, file->f_path.dentry->d_inode, buf);
453 fput(file);
456 return error;
459 asmlinkage int solaris_statvfs64(u32 path, u32 buf)
461 struct nameidata nd;
462 int error;
464 lock_kernel();
465 error = user_path_walk(A(path), &nd);
466 if (!error) {
467 struct inode * inode = nd.dentry->d_inode;
468 error = report_statvfs64(nd.mnt, inode, buf);
469 path_release(&nd);
471 unlock_kernel();
472 return error;
475 asmlinkage int solaris_fstatvfs64(unsigned int fd, u32 buf)
477 struct file * file;
478 int error;
480 error = -EBADF;
481 file = fget(fd);
482 if (file) {
483 lock_kernel();
484 error = report_statvfs64(file->f_path.mnt, file->f_path.dentry->d_inode, buf);
485 unlock_kernel();
486 fput(file);
488 return error;
491 extern asmlinkage long sparc32_open(const char * filename, int flags, int mode);
493 asmlinkage int solaris_open(u32 fname, int flags, u32 mode)
495 const char *filename = (const char *)(long)fname;
496 int fl = flags & 0xf;
498 /* Translate flags first. */
499 if (flags & 0x2000) fl |= O_LARGEFILE;
500 if (flags & 0x8050) fl |= O_SYNC;
501 if (flags & 0x80) fl |= O_NONBLOCK;
502 if (flags & 0x100) fl |= O_CREAT;
503 if (flags & 0x200) fl |= O_TRUNC;
504 if (flags & 0x400) fl |= O_EXCL;
505 if (flags & 0x800) fl |= O_NOCTTY;
506 flags = fl;
508 return sparc32_open(filename, flags, mode);
511 #define SOL_F_SETLK 6
512 #define SOL_F_SETLKW 7
513 #define SOL_F_FREESP 11
514 #define SOL_F_ISSTREAM 13
515 #define SOL_F_GETLK 14
516 #define SOL_F_PRIV 15
517 #define SOL_F_NPRIV 16
518 #define SOL_F_QUOTACTL 17
519 #define SOL_F_BLOCKS 18
520 #define SOL_F_BLKSIZE 19
521 #define SOL_F_GETOWN 23
522 #define SOL_F_SETOWN 24
524 struct sol_flock {
525 short l_type;
526 short l_whence;
527 u32 l_start;
528 u32 l_len;
529 s32 l_sysid;
530 s32 l_pid;
531 s32 l_pad[4];
534 asmlinkage int solaris_fcntl(unsigned fd, unsigned cmd, u32 arg)
536 int (*sys_fcntl)(unsigned,unsigned,unsigned long) =
537 (int (*)(unsigned,unsigned,unsigned long))SYS(fcntl);
538 int ret, flags;
540 switch (cmd) {
541 case F_DUPFD:
542 case F_GETFD:
543 case F_SETFD: return sys_fcntl(fd, cmd, (unsigned long)arg);
544 case F_GETFL:
545 flags = sys_fcntl(fd, cmd, 0);
546 ret = flags & 0xf;
547 if (flags & O_SYNC) ret |= 0x8050;
548 if (flags & O_NONBLOCK) ret |= 0x80;
549 return ret;
550 case F_SETFL:
551 flags = arg & 0xf;
552 if (arg & 0x8050) flags |= O_SYNC;
553 if (arg & 0x80) flags |= O_NONBLOCK;
554 return sys_fcntl(fd, cmd, (long)flags);
555 case SOL_F_GETLK:
556 case SOL_F_SETLK:
557 case SOL_F_SETLKW:
559 struct flock f;
560 struct sol_flock __user *p = A(arg);
561 mm_segment_t old_fs = get_fs();
563 switch (cmd) {
564 case SOL_F_GETLK: cmd = F_GETLK; break;
565 case SOL_F_SETLK: cmd = F_SETLK; break;
566 case SOL_F_SETLKW: cmd = F_SETLKW; break;
569 if (get_user (f.l_type, &p->l_type) ||
570 __get_user (f.l_whence, &p->l_whence) ||
571 __get_user (f.l_start, &p->l_start) ||
572 __get_user (f.l_len, &p->l_len) ||
573 __get_user (f.l_pid, &p->l_sysid))
574 return -EFAULT;
576 set_fs(KERNEL_DS);
577 ret = sys_fcntl(fd, cmd, (unsigned long)&f);
578 set_fs(old_fs);
580 if (__put_user (f.l_type, &p->l_type) ||
581 __put_user (f.l_whence, &p->l_whence) ||
582 __put_user (f.l_start, &p->l_start) ||
583 __put_user (f.l_len, &p->l_len) ||
584 __put_user (f.l_pid, &p->l_pid) ||
585 __put_user (0, &p->l_sysid))
586 return -EFAULT;
588 return ret;
590 case SOL_F_FREESP:
592 int length;
593 int (*sys_newftruncate)(unsigned int, unsigned long)=
594 (int (*)(unsigned int, unsigned long))SYS(ftruncate);
596 if (get_user(length, &((struct sol_flock __user *)A(arg))->l_start))
597 return -EFAULT;
599 return sys_newftruncate(fd, length);
602 return -EINVAL;
605 asmlinkage int solaris_ulimit(int cmd, int val)
607 switch (cmd) {
608 case 1: /* UL_GETFSIZE - in 512B chunks */
609 return current->signal->rlim[RLIMIT_FSIZE].rlim_cur >> 9;
610 case 2: /* UL_SETFSIZE */
611 if ((unsigned long)val > (LONG_MAX>>9)) return -ERANGE;
612 val <<= 9;
613 task_lock(current->group_leader);
614 if (val > current->signal->rlim[RLIMIT_FSIZE].rlim_max) {
615 if (!capable(CAP_SYS_RESOURCE)) {
616 task_unlock(current->group_leader);
617 return -EPERM;
619 current->signal->rlim[RLIMIT_FSIZE].rlim_max = val;
621 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = val;
622 task_unlock(current->group_leader);
623 return 0;
624 case 3: /* UL_GMEMLIM */
625 return current->signal->rlim[RLIMIT_DATA].rlim_cur;
626 case 4: /* UL_GDESLIM */
627 return sysctl_nr_open;
629 return -EINVAL;
632 /* At least at the time I'm writing this, Linux doesn't have ACLs, so we
633 just fake this */
634 asmlinkage int solaris_acl(u32 filename, int cmd, int nentries, u32 aclbufp)
636 return -ENOSYS;
639 asmlinkage int solaris_facl(unsigned int fd, int cmd, int nentries, u32 aclbufp)
641 return -ENOSYS;
644 asmlinkage int solaris_pread(unsigned int fd, char __user *buf, u32 count, u32 pos)
646 ssize_t (*sys_pread64)(unsigned int, char __user *, size_t, loff_t) =
647 (ssize_t (*)(unsigned int, char __user *, size_t, loff_t))SYS(pread64);
649 return sys_pread64(fd, buf, count, (loff_t)pos);
652 asmlinkage int solaris_pwrite(unsigned int fd, char __user *buf, u32 count, u32 pos)
654 ssize_t (*sys_pwrite64)(unsigned int, char __user *, size_t, loff_t) =
655 (ssize_t (*)(unsigned int, char __user *, size_t, loff_t))SYS(pwrite64);
657 return sys_pwrite64(fd, buf, count, (loff_t)pos);
660 /* POSIX.1 names */
661 #define _PC_LINK_MAX 1
662 #define _PC_MAX_CANON 2
663 #define _PC_MAX_INPUT 3
664 #define _PC_NAME_MAX 4
665 #define _PC_PATH_MAX 5
666 #define _PC_PIPE_BUF 6
667 #define _PC_NO_TRUNC 7
668 #define _PC_VDISABLE 8
669 #define _PC_CHOWN_RESTRICTED 9
670 /* POSIX.4 names */
671 #define _PC_ASYNC_IO 10
672 #define _PC_PRIO_IO 11
673 #define _PC_SYNC_IO 12
674 #define _PC_LAST 12
676 /* This is not a real and complete implementation yet, just to keep
677 * the easy Solaris binaries happy.
679 asmlinkage int solaris_fpathconf(int fd, int name)
681 int ret;
683 switch(name) {
684 case _PC_LINK_MAX:
685 ret = LINK_MAX;
686 break;
687 case _PC_MAX_CANON:
688 ret = MAX_CANON;
689 break;
690 case _PC_MAX_INPUT:
691 ret = MAX_INPUT;
692 break;
693 case _PC_NAME_MAX:
694 ret = NAME_MAX;
695 break;
696 case _PC_PATH_MAX:
697 ret = PATH_MAX;
698 break;
699 case _PC_PIPE_BUF:
700 ret = PIPE_BUF;
701 break;
702 case _PC_CHOWN_RESTRICTED:
703 ret = 1;
704 break;
705 case _PC_NO_TRUNC:
706 case _PC_VDISABLE:
707 ret = 0;
708 break;
709 default:
710 ret = -EINVAL;
711 break;
713 return ret;
716 asmlinkage int solaris_pathconf(u32 path, int name)
718 return solaris_fpathconf(0, name);
721 /* solaris_llseek returns long long - quite difficult */
722 asmlinkage long solaris_llseek(struct pt_regs *regs, u32 off_hi, u32 off_lo, int whence)
724 int (*sys_llseek)(unsigned int, unsigned long, unsigned long, loff_t __user *, unsigned int) =
725 (int (*)(unsigned int, unsigned long, unsigned long, loff_t __user *, unsigned int))SYS(_llseek);
726 int ret;
727 mm_segment_t old_fs = get_fs();
728 loff_t retval;
730 set_fs(KERNEL_DS);
731 ret = sys_llseek((unsigned int)regs->u_regs[UREG_I0], off_hi, off_lo, &retval, whence);
732 set_fs(old_fs);
733 if (ret < 0) return ret;
734 regs->u_regs[UREG_I1] = (u32)retval;
735 return (retval >> 32);
738 /* Have to mask out all but lower 3 bits */
739 asmlinkage int solaris_access(u32 filename, long mode)
741 int (*sys_access)(const char __user *, int) =
742 (int (*)(const char __user *, int))SYS(access);
744 return sys_access(A(filename), mode & 7);