[SCSI] drivers/scsi/dpt_i2o.c: fix compile warnings
[linux/fpc-iii.git] / arch / sparc64 / solaris / fs.c
blobd7c99fa89661de5dacf5d45b1a625dc26aeb9ac5
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/fs.h>
14 #include <linux/namei.h>
15 #include <linux/mm.h>
16 #include <linux/file.h>
17 #include <linux/stat.h>
18 #include <linux/smp_lock.h>
19 #include <linux/limits.h>
20 #include <linux/resource.h>
21 #include <linux/quotaops.h>
22 #include <linux/mount.h>
23 #include <linux/vfs.h>
25 #include <asm/uaccess.h>
26 #include <asm/string.h>
27 #include <asm/ptrace.h>
29 #include "conv.h"
31 #define R3_VERSION 1
32 #define R4_VERSION 2
34 typedef struct {
35 s32 tv_sec;
36 s32 tv_nsec;
37 } timestruct_t;
39 struct sol_stat {
40 u32 st_dev;
41 s32 st_pad1[3]; /* network id */
42 u32 st_ino;
43 u32 st_mode;
44 u32 st_nlink;
45 u32 st_uid;
46 u32 st_gid;
47 u32 st_rdev;
48 s32 st_pad2[2];
49 s32 st_size;
50 s32 st_pad3; /* st_size, off_t expansion */
51 timestruct_t st_atime;
52 timestruct_t st_mtime;
53 timestruct_t st_ctime;
54 s32 st_blksize;
55 s32 st_blocks;
56 char st_fstype[16];
57 s32 st_pad4[8]; /* expansion area */
60 struct sol_stat64 {
61 u32 st_dev;
62 s32 st_pad1[3]; /* network id */
63 u64 st_ino;
64 u32 st_mode;
65 u32 st_nlink;
66 u32 st_uid;
67 u32 st_gid;
68 u32 st_rdev;
69 s32 st_pad2[2];
70 s64 st_size;
71 timestruct_t st_atime;
72 timestruct_t st_mtime;
73 timestruct_t st_ctime;
74 s64 st_blksize;
75 s32 st_blocks;
76 char st_fstype[16];
77 s32 st_pad4[4]; /* expansion area */
80 #define UFSMAGIC (((unsigned)'u'<<24)||((unsigned)'f'<<16)||((unsigned)'s'<<8))
82 static inline int putstat(struct sol_stat __user *ubuf, struct kstat *kbuf)
84 if (kbuf->size > MAX_NON_LFS ||
85 !sysv_valid_dev(kbuf->dev) ||
86 !sysv_valid_dev(kbuf->rdev))
87 return -EOVERFLOW;
88 if (put_user (sysv_encode_dev(kbuf->dev), &ubuf->st_dev) ||
89 __put_user (kbuf->ino, &ubuf->st_ino) ||
90 __put_user (kbuf->mode, &ubuf->st_mode) ||
91 __put_user (kbuf->nlink, &ubuf->st_nlink) ||
92 __put_user (kbuf->uid, &ubuf->st_uid) ||
93 __put_user (kbuf->gid, &ubuf->st_gid) ||
94 __put_user (sysv_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
95 __put_user (kbuf->size, &ubuf->st_size) ||
96 __put_user (kbuf->atime.tv_sec, &ubuf->st_atime.tv_sec) ||
97 __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime.tv_nsec) ||
98 __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime.tv_sec) ||
99 __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime.tv_nsec) ||
100 __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime.tv_sec) ||
101 __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime.tv_nsec) ||
102 __put_user (kbuf->blksize, &ubuf->st_blksize) ||
103 __put_user (kbuf->blocks, &ubuf->st_blocks) ||
104 __put_user (UFSMAGIC, (unsigned __user *)ubuf->st_fstype))
105 return -EFAULT;
106 return 0;
109 static inline int putstat64(struct sol_stat64 __user *ubuf, struct kstat *kbuf)
111 if (!sysv_valid_dev(kbuf->dev) || !sysv_valid_dev(kbuf->rdev))
112 return -EOVERFLOW;
113 if (put_user (sysv_encode_dev(kbuf->dev), &ubuf->st_dev) ||
114 __put_user (kbuf->ino, &ubuf->st_ino) ||
115 __put_user (kbuf->mode, &ubuf->st_mode) ||
116 __put_user (kbuf->nlink, &ubuf->st_nlink) ||
117 __put_user (kbuf->uid, &ubuf->st_uid) ||
118 __put_user (kbuf->gid, &ubuf->st_gid) ||
119 __put_user (sysv_encode_dev(kbuf->rdev), &ubuf->st_rdev) ||
120 __put_user (kbuf->size, &ubuf->st_size) ||
121 __put_user (kbuf->atime.tv_sec, &ubuf->st_atime.tv_sec) ||
122 __put_user (kbuf->atime.tv_nsec, &ubuf->st_atime.tv_nsec) ||
123 __put_user (kbuf->mtime.tv_sec, &ubuf->st_mtime.tv_sec) ||
124 __put_user (kbuf->mtime.tv_nsec, &ubuf->st_mtime.tv_nsec) ||
125 __put_user (kbuf->ctime.tv_sec, &ubuf->st_ctime.tv_sec) ||
126 __put_user (kbuf->ctime.tv_nsec, &ubuf->st_ctime.tv_nsec) ||
127 __put_user (kbuf->blksize, &ubuf->st_blksize) ||
128 __put_user (kbuf->blocks, &ubuf->st_blocks) ||
129 __put_user (UFSMAGIC, (unsigned __user *)ubuf->st_fstype))
130 return -EFAULT;
131 return 0;
134 asmlinkage int solaris_stat(u32 filename, u32 statbuf)
136 struct kstat s;
137 int ret = vfs_stat(A(filename), &s);
138 if (!ret)
139 return putstat(A(statbuf), &s);
140 return ret;
143 asmlinkage int solaris_xstat(int vers, u32 filename, u32 statbuf)
145 /* Solaris doesn't bother with looking at vers, so we do neither */
146 return solaris_stat(filename, statbuf);
149 asmlinkage int solaris_stat64(u32 filename, u32 statbuf)
151 struct kstat s;
152 int ret = vfs_stat(A(filename), &s);
153 if (!ret)
154 return putstat64(A(statbuf), &s);
155 return ret;
158 asmlinkage int solaris_lstat(u32 filename, u32 statbuf)
160 struct kstat s;
161 int ret = vfs_lstat(A(filename), &s);
162 if (!ret)
163 return putstat(A(statbuf), &s);
164 return ret;
167 asmlinkage int solaris_lxstat(int vers, u32 filename, u32 statbuf)
169 return solaris_lstat(filename, statbuf);
172 asmlinkage int solaris_lstat64(u32 filename, u32 statbuf)
174 struct kstat s;
175 int ret = vfs_lstat(A(filename), &s);
176 if (!ret)
177 return putstat64(A(statbuf), &s);
178 return ret;
181 asmlinkage int solaris_fstat(unsigned int fd, u32 statbuf)
183 struct kstat s;
184 int ret = vfs_fstat(fd, &s);
185 if (!ret)
186 return putstat(A(statbuf), &s);
187 return ret;
190 asmlinkage int solaris_fxstat(int vers, u32 fd, u32 statbuf)
192 return solaris_fstat(fd, statbuf);
195 asmlinkage int solaris_fstat64(unsigned int fd, u32 statbuf)
197 struct kstat s;
198 int ret = vfs_fstat(fd, &s);
199 if (!ret)
200 return putstat64(A(statbuf), &s);
201 return ret;
204 asmlinkage int solaris_mknod(u32 path, u32 mode, s32 dev)
206 int (*sys_mknod)(const char __user *,int,unsigned) =
207 (int (*)(const char __user *,int,unsigned))SYS(mknod);
208 int major = sysv_major(dev);
209 int minor = sysv_minor(dev);
211 /* minor is guaranteed to be OK for MKDEV, major might be not */
212 if (major > 0xfff)
213 return -EINVAL;
214 return sys_mknod(A(path), mode, new_encode_dev(MKDEV(major,minor)));
217 asmlinkage int solaris_xmknod(int vers, u32 path, u32 mode, s32 dev)
219 return solaris_mknod(path, mode, dev);
222 asmlinkage int solaris_getdents64(unsigned int fd, void __user *dirent, unsigned int count)
224 int (*sys_getdents)(unsigned int, void __user *, unsigned int) =
225 (int (*)(unsigned int, void __user *, unsigned int))SYS(getdents);
227 return sys_getdents(fd, dirent, count);
230 /* This statfs thingie probably will go in the near future, but... */
232 struct sol_statfs {
233 short f_type;
234 s32 f_bsize;
235 s32 f_frsize;
236 s32 f_blocks;
237 s32 f_bfree;
238 u32 f_files;
239 u32 f_ffree;
240 char f_fname[6];
241 char f_fpack[6];
244 asmlinkage int solaris_statfs(u32 path, u32 buf, int len, int fstype)
246 int ret;
247 struct statfs s;
248 mm_segment_t old_fs = get_fs();
249 int (*sys_statfs)(const char __user *,struct statfs __user *) =
250 (int (*)(const char __user *,struct statfs __user *))SYS(statfs);
251 struct sol_statfs __user *ss = A(buf);
253 if (len != sizeof(struct sol_statfs)) return -EINVAL;
254 if (!fstype) {
255 /* FIXME: mixing userland and kernel pointers */
256 set_fs (KERNEL_DS);
257 ret = sys_statfs(A(path), &s);
258 set_fs (old_fs);
259 if (!ret) {
260 if (put_user (s.f_type, &ss->f_type) ||
261 __put_user (s.f_bsize, &ss->f_bsize) ||
262 __put_user (0, &ss->f_frsize) ||
263 __put_user (s.f_blocks, &ss->f_blocks) ||
264 __put_user (s.f_bfree, &ss->f_bfree) ||
265 __put_user (s.f_files, &ss->f_files) ||
266 __put_user (s.f_ffree, &ss->f_ffree) ||
267 __clear_user (&ss->f_fname, 12))
268 return -EFAULT;
270 return ret;
272 /* Linux can't stat unmounted filesystems so we
273 * simply lie and claim 100MB of 1GB is free. Sorry.
275 if (put_user (fstype, &ss->f_type) ||
276 __put_user (1024, &ss->f_bsize) ||
277 __put_user (0, &ss->f_frsize) ||
278 __put_user (1024*1024, &ss->f_blocks) ||
279 __put_user (100*1024, &ss->f_bfree) ||
280 __put_user (60000, &ss->f_files) ||
281 __put_user (50000, &ss->f_ffree) ||
282 __clear_user (&ss->f_fname, 12))
283 return -EFAULT;
284 return 0;
287 asmlinkage int solaris_fstatfs(u32 fd, u32 buf, int len, int fstype)
289 int ret;
290 struct statfs s;
291 mm_segment_t old_fs = get_fs();
292 int (*sys_fstatfs)(unsigned,struct statfs __user *) =
293 (int (*)(unsigned,struct statfs __user *))SYS(fstatfs);
294 struct sol_statfs __user *ss = A(buf);
296 if (len != sizeof(struct sol_statfs)) return -EINVAL;
297 if (!fstype) {
298 set_fs (KERNEL_DS);
299 ret = sys_fstatfs(fd, &s);
300 set_fs (old_fs);
301 if (!ret) {
302 if (put_user (s.f_type, &ss->f_type) ||
303 __put_user (s.f_bsize, &ss->f_bsize) ||
304 __put_user (0, &ss->f_frsize) ||
305 __put_user (s.f_blocks, &ss->f_blocks) ||
306 __put_user (s.f_bfree, &ss->f_bfree) ||
307 __put_user (s.f_files, &ss->f_files) ||
308 __put_user (s.f_ffree, &ss->f_ffree) ||
309 __clear_user (&ss->f_fname, 12))
310 return -EFAULT;
312 return ret;
314 /* Otherwise fstatfs is the same as statfs */
315 return solaris_statfs(0, buf, len, fstype);
318 struct sol_statvfs {
319 u32 f_bsize;
320 u32 f_frsize;
321 u32 f_blocks;
322 u32 f_bfree;
323 u32 f_bavail;
324 u32 f_files;
325 u32 f_ffree;
326 u32 f_favail;
327 u32 f_fsid;
328 char f_basetype[16];
329 u32 f_flag;
330 u32 f_namemax;
331 char f_fstr[32];
332 u32 f_filler[16];
335 struct sol_statvfs64 {
336 u32 f_bsize;
337 u32 f_frsize;
338 u64 f_blocks;
339 u64 f_bfree;
340 u64 f_bavail;
341 u64 f_files;
342 u64 f_ffree;
343 u64 f_favail;
344 u32 f_fsid;
345 char f_basetype[16];
346 u32 f_flag;
347 u32 f_namemax;
348 char f_fstr[32];
349 u32 f_filler[16];
352 static int report_statvfs(struct vfsmount *mnt, struct inode *inode, u32 buf)
354 struct kstatfs s;
355 int error;
356 struct sol_statvfs __user *ss = A(buf);
358 error = vfs_statfs(mnt->mnt_sb, &s);
359 if (!error) {
360 const char *p = mnt->mnt_sb->s_type->name;
361 int i = 0;
362 int j = strlen (p);
364 if (j > 15) j = 15;
365 if (IS_RDONLY(inode)) i = 1;
366 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
367 if (!sysv_valid_dev(inode->i_sb->s_dev))
368 return -EOVERFLOW;
369 if (put_user (s.f_bsize, &ss->f_bsize) ||
370 __put_user (0, &ss->f_frsize) ||
371 __put_user (s.f_blocks, &ss->f_blocks) ||
372 __put_user (s.f_bfree, &ss->f_bfree) ||
373 __put_user (s.f_bavail, &ss->f_bavail) ||
374 __put_user (s.f_files, &ss->f_files) ||
375 __put_user (s.f_ffree, &ss->f_ffree) ||
376 __put_user (s.f_ffree, &ss->f_favail) ||
377 __put_user (sysv_encode_dev(inode->i_sb->s_dev), &ss->f_fsid) ||
378 __copy_to_user (ss->f_basetype,p,j) ||
379 __put_user (0, (char __user *)&ss->f_basetype[j]) ||
380 __put_user (s.f_namelen, &ss->f_namemax) ||
381 __put_user (i, &ss->f_flag) ||
382 __clear_user (&ss->f_fstr, 32))
383 return -EFAULT;
385 return error;
388 static int report_statvfs64(struct vfsmount *mnt, struct inode *inode, u32 buf)
390 struct kstatfs s;
391 int error;
392 struct sol_statvfs64 __user *ss = A(buf);
394 error = vfs_statfs(mnt->mnt_sb, &s);
395 if (!error) {
396 const char *p = mnt->mnt_sb->s_type->name;
397 int i = 0;
398 int j = strlen (p);
400 if (j > 15) j = 15;
401 if (IS_RDONLY(inode)) i = 1;
402 if (mnt->mnt_flags & MNT_NOSUID) i |= 2;
403 if (!sysv_valid_dev(inode->i_sb->s_dev))
404 return -EOVERFLOW;
405 if (put_user (s.f_bsize, &ss->f_bsize) ||
406 __put_user (0, &ss->f_frsize) ||
407 __put_user (s.f_blocks, &ss->f_blocks) ||
408 __put_user (s.f_bfree, &ss->f_bfree) ||
409 __put_user (s.f_bavail, &ss->f_bavail) ||
410 __put_user (s.f_files, &ss->f_files) ||
411 __put_user (s.f_ffree, &ss->f_ffree) ||
412 __put_user (s.f_ffree, &ss->f_favail) ||
413 __put_user (sysv_encode_dev(inode->i_sb->s_dev), &ss->f_fsid) ||
414 __copy_to_user (ss->f_basetype,p,j) ||
415 __put_user (0, (char __user *)&ss->f_basetype[j]) ||
416 __put_user (s.f_namelen, &ss->f_namemax) ||
417 __put_user (i, &ss->f_flag) ||
418 __clear_user (&ss->f_fstr, 32))
419 return -EFAULT;
421 return error;
424 asmlinkage int solaris_statvfs(u32 path, u32 buf)
426 struct nameidata nd;
427 int error;
429 error = user_path_walk(A(path),&nd);
430 if (!error) {
431 struct inode * inode = nd.dentry->d_inode;
432 error = report_statvfs(nd.mnt, inode, buf);
433 path_release(&nd);
435 return error;
438 asmlinkage int solaris_fstatvfs(unsigned int fd, u32 buf)
440 struct file * file;
441 int error;
443 error = -EBADF;
444 file = fget(fd);
445 if (file) {
446 error = report_statvfs(file->f_vfsmnt, file->f_dentry->d_inode, buf);
447 fput(file);
450 return error;
453 asmlinkage int solaris_statvfs64(u32 path, u32 buf)
455 struct nameidata nd;
456 int error;
458 lock_kernel();
459 error = user_path_walk(A(path), &nd);
460 if (!error) {
461 struct inode * inode = nd.dentry->d_inode;
462 error = report_statvfs64(nd.mnt, inode, buf);
463 path_release(&nd);
465 unlock_kernel();
466 return error;
469 asmlinkage int solaris_fstatvfs64(unsigned int fd, u32 buf)
471 struct file * file;
472 int error;
474 error = -EBADF;
475 file = fget(fd);
476 if (file) {
477 lock_kernel();
478 error = report_statvfs64(file->f_vfsmnt, file->f_dentry->d_inode, buf);
479 unlock_kernel();
480 fput(file);
482 return error;
485 extern asmlinkage long sparc32_open(const char * filename, int flags, int mode);
487 asmlinkage int solaris_open(u32 fname, int flags, u32 mode)
489 const char *filename = (const char *)(long)fname;
490 int fl = flags & 0xf;
492 /* Translate flags first. */
493 if (flags & 0x2000) fl |= O_LARGEFILE;
494 if (flags & 0x8050) fl |= O_SYNC;
495 if (flags & 0x80) fl |= O_NONBLOCK;
496 if (flags & 0x100) fl |= O_CREAT;
497 if (flags & 0x200) fl |= O_TRUNC;
498 if (flags & 0x400) fl |= O_EXCL;
499 if (flags & 0x800) fl |= O_NOCTTY;
500 flags = fl;
502 return sparc32_open(filename, flags, mode);
505 #define SOL_F_SETLK 6
506 #define SOL_F_SETLKW 7
507 #define SOL_F_FREESP 11
508 #define SOL_F_ISSTREAM 13
509 #define SOL_F_GETLK 14
510 #define SOL_F_PRIV 15
511 #define SOL_F_NPRIV 16
512 #define SOL_F_QUOTACTL 17
513 #define SOL_F_BLOCKS 18
514 #define SOL_F_BLKSIZE 19
515 #define SOL_F_GETOWN 23
516 #define SOL_F_SETOWN 24
518 struct sol_flock {
519 short l_type;
520 short l_whence;
521 u32 l_start;
522 u32 l_len;
523 s32 l_sysid;
524 s32 l_pid;
525 s32 l_pad[4];
528 asmlinkage int solaris_fcntl(unsigned fd, unsigned cmd, u32 arg)
530 int (*sys_fcntl)(unsigned,unsigned,unsigned long) =
531 (int (*)(unsigned,unsigned,unsigned long))SYS(fcntl);
532 int ret, flags;
534 switch (cmd) {
535 case F_DUPFD:
536 case F_GETFD:
537 case F_SETFD: return sys_fcntl(fd, cmd, (unsigned long)arg);
538 case F_GETFL:
539 flags = sys_fcntl(fd, cmd, 0);
540 ret = flags & 0xf;
541 if (flags & O_SYNC) ret |= 0x8050;
542 if (flags & O_NONBLOCK) ret |= 0x80;
543 return ret;
544 case F_SETFL:
545 flags = arg & 0xf;
546 if (arg & 0x8050) flags |= O_SYNC;
547 if (arg & 0x80) flags |= O_NONBLOCK;
548 return sys_fcntl(fd, cmd, (long)flags);
549 case SOL_F_GETLK:
550 case SOL_F_SETLK:
551 case SOL_F_SETLKW:
553 struct flock f;
554 struct sol_flock __user *p = A(arg);
555 mm_segment_t old_fs = get_fs();
557 switch (cmd) {
558 case SOL_F_GETLK: cmd = F_GETLK; break;
559 case SOL_F_SETLK: cmd = F_SETLK; break;
560 case SOL_F_SETLKW: cmd = F_SETLKW; break;
563 if (get_user (f.l_type, &p->l_type) ||
564 __get_user (f.l_whence, &p->l_whence) ||
565 __get_user (f.l_start, &p->l_start) ||
566 __get_user (f.l_len, &p->l_len) ||
567 __get_user (f.l_pid, &p->l_sysid))
568 return -EFAULT;
570 set_fs(KERNEL_DS);
571 ret = sys_fcntl(fd, cmd, (unsigned long)&f);
572 set_fs(old_fs);
574 if (__put_user (f.l_type, &p->l_type) ||
575 __put_user (f.l_whence, &p->l_whence) ||
576 __put_user (f.l_start, &p->l_start) ||
577 __put_user (f.l_len, &p->l_len) ||
578 __put_user (f.l_pid, &p->l_pid) ||
579 __put_user (0, &p->l_sysid))
580 return -EFAULT;
582 return ret;
584 case SOL_F_FREESP:
586 int length;
587 int (*sys_newftruncate)(unsigned int, unsigned long)=
588 (int (*)(unsigned int, unsigned long))SYS(ftruncate);
590 if (get_user(length, &((struct sol_flock __user *)A(arg))->l_start))
591 return -EFAULT;
593 return sys_newftruncate(fd, length);
596 return -EINVAL;
599 asmlinkage int solaris_ulimit(int cmd, int val)
601 switch (cmd) {
602 case 1: /* UL_GETFSIZE - in 512B chunks */
603 return current->signal->rlim[RLIMIT_FSIZE].rlim_cur >> 9;
604 case 2: /* UL_SETFSIZE */
605 if ((unsigned long)val > (LONG_MAX>>9)) return -ERANGE;
606 val <<= 9;
607 task_lock(current->group_leader);
608 if (val > current->signal->rlim[RLIMIT_FSIZE].rlim_max) {
609 if (!capable(CAP_SYS_RESOURCE)) {
610 task_unlock(current->group_leader);
611 return -EPERM;
613 current->signal->rlim[RLIMIT_FSIZE].rlim_max = val;
615 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = val;
616 task_unlock(current->group_leader);
617 return 0;
618 case 3: /* UL_GMEMLIM */
619 return current->signal->rlim[RLIMIT_DATA].rlim_cur;
620 case 4: /* UL_GDESLIM */
621 return NR_OPEN;
623 return -EINVAL;
626 /* At least at the time I'm writing this, Linux doesn't have ACLs, so we
627 just fake this */
628 asmlinkage int solaris_acl(u32 filename, int cmd, int nentries, u32 aclbufp)
630 return -ENOSYS;
633 asmlinkage int solaris_facl(unsigned int fd, int cmd, int nentries, u32 aclbufp)
635 return -ENOSYS;
638 asmlinkage int solaris_pread(unsigned int fd, char __user *buf, u32 count, u32 pos)
640 ssize_t (*sys_pread64)(unsigned int, char __user *, size_t, loff_t) =
641 (ssize_t (*)(unsigned int, char __user *, size_t, loff_t))SYS(pread64);
643 return sys_pread64(fd, buf, count, (loff_t)pos);
646 asmlinkage int solaris_pwrite(unsigned int fd, char __user *buf, u32 count, u32 pos)
648 ssize_t (*sys_pwrite64)(unsigned int, char __user *, size_t, loff_t) =
649 (ssize_t (*)(unsigned int, char __user *, size_t, loff_t))SYS(pwrite64);
651 return sys_pwrite64(fd, buf, count, (loff_t)pos);
654 /* POSIX.1 names */
655 #define _PC_LINK_MAX 1
656 #define _PC_MAX_CANON 2
657 #define _PC_MAX_INPUT 3
658 #define _PC_NAME_MAX 4
659 #define _PC_PATH_MAX 5
660 #define _PC_PIPE_BUF 6
661 #define _PC_NO_TRUNC 7
662 #define _PC_VDISABLE 8
663 #define _PC_CHOWN_RESTRICTED 9
664 /* POSIX.4 names */
665 #define _PC_ASYNC_IO 10
666 #define _PC_PRIO_IO 11
667 #define _PC_SYNC_IO 12
668 #define _PC_LAST 12
670 /* This is not a real and complete implementation yet, just to keep
671 * the easy Solaris binaries happy.
673 asmlinkage int solaris_fpathconf(int fd, int name)
675 int ret;
677 switch(name) {
678 case _PC_LINK_MAX:
679 ret = LINK_MAX;
680 break;
681 case _PC_MAX_CANON:
682 ret = MAX_CANON;
683 break;
684 case _PC_MAX_INPUT:
685 ret = MAX_INPUT;
686 break;
687 case _PC_NAME_MAX:
688 ret = NAME_MAX;
689 break;
690 case _PC_PATH_MAX:
691 ret = PATH_MAX;
692 break;
693 case _PC_PIPE_BUF:
694 ret = PIPE_BUF;
695 break;
696 case _PC_CHOWN_RESTRICTED:
697 ret = 1;
698 break;
699 case _PC_NO_TRUNC:
700 case _PC_VDISABLE:
701 ret = 0;
702 break;
703 default:
704 ret = -EINVAL;
705 break;
707 return ret;
710 asmlinkage int solaris_pathconf(u32 path, int name)
712 return solaris_fpathconf(0, name);
715 /* solaris_llseek returns long long - quite difficult */
716 asmlinkage long solaris_llseek(struct pt_regs *regs, u32 off_hi, u32 off_lo, int whence)
718 int (*sys_llseek)(unsigned int, unsigned long, unsigned long, loff_t __user *, unsigned int) =
719 (int (*)(unsigned int, unsigned long, unsigned long, loff_t __user *, unsigned int))SYS(_llseek);
720 int ret;
721 mm_segment_t old_fs = get_fs();
722 loff_t retval;
724 set_fs(KERNEL_DS);
725 ret = sys_llseek((unsigned int)regs->u_regs[UREG_I0], off_hi, off_lo, &retval, whence);
726 set_fs(old_fs);
727 if (ret < 0) return ret;
728 regs->u_regs[UREG_I1] = (u32)retval;
729 return (retval >> 32);
732 /* Have to mask out all but lower 3 bits */
733 asmlinkage int solaris_access(u32 filename, long mode)
735 int (*sys_access)(const char __user *, int) =
736 (int (*)(const char __user *, int))SYS(access);
738 return sys_access(A(filename), mode & 7);