aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64/solaris/fs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/sparc64/solaris/fs.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/sparc64/solaris/fs.c')
-rw-r--r--arch/sparc64/solaris/fs.c739
1 files changed, 739 insertions, 0 deletions
diff --git a/arch/sparc64/solaris/fs.c b/arch/sparc64/solaris/fs.c
new file mode 100644
index 000000000000..d7c99fa89661
--- /dev/null
+++ b/arch/sparc64/solaris/fs.c
@@ -0,0 +1,739 @@
1/* $Id: fs.c,v 1.27 2002/02/08 03:57:14 davem Exp $
2 * fs.c: fs related syscall emulation for Solaris
3 *
4 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
5 *
6 * 1999-08-19 Implemented solaris F_FREESP (truncate)
7 * fcntl, by Jason Rappleye (rappleye@ccr.buffalo.edu)
8 */
9
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>
24
25#include <asm/uaccess.h>
26#include <asm/string.h>
27#include <asm/ptrace.h>
28
29#include "conv.h"
30
31#define R3_VERSION 1
32#define R4_VERSION 2
33
34typedef struct {
35 s32 tv_sec;
36 s32 tv_nsec;
37} timestruct_t;
38
39struct 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 */
58};
59
60struct 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 */
78};
79
80#define UFSMAGIC (((unsigned)'u'<<24)||((unsigned)'f'<<16)||((unsigned)'s'<<8))
81
82static inline int putstat(struct sol_stat __user *ubuf, struct kstat *kbuf)
83{
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;
107}
108
109static inline int putstat64(struct sol_stat64 __user *ubuf, struct kstat *kbuf)
110{
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;
132}
133
134asmlinkage int solaris_stat(u32 filename, u32 statbuf)
135{
136 struct kstat s;
137 int ret = vfs_stat(A(filename), &s);
138 if (!ret)
139 return putstat(A(statbuf), &s);
140 return ret;
141}
142
143asmlinkage int solaris_xstat(int vers, u32 filename, u32 statbuf)
144{
145 /* Solaris doesn't bother with looking at vers, so we do neither */
146 return solaris_stat(filename, statbuf);
147}
148
149asmlinkage int solaris_stat64(u32 filename, u32 statbuf)
150{
151 struct kstat s;
152 int ret = vfs_stat(A(filename), &s);
153 if (!ret)
154 return putstat64(A(statbuf), &s);
155 return ret;
156}
157
158asmlinkage int solaris_lstat(u32 filename, u32 statbuf)
159{
160 struct kstat s;
161 int ret = vfs_lstat(A(filename), &s);
162 if (!ret)
163 return putstat(A(statbuf), &s);
164 return ret;
165}
166
167asmlinkage int solaris_lxstat(int vers, u32 filename, u32 statbuf)
168{
169 return solaris_lstat(filename, statbuf);
170}
171
172asmlinkage int solaris_lstat64(u32 filename, u32 statbuf)
173{
174 struct kstat s;
175 int ret = vfs_lstat(A(filename), &s);
176 if (!ret)
177 return putstat64(A(statbuf), &s);
178 return ret;
179}
180
181asmlinkage int solaris_fstat(unsigned int fd, u32 statbuf)
182{
183 struct kstat s;
184 int ret = vfs_fstat(fd, &s);
185 if (!ret)
186 return putstat(A(statbuf), &s);
187 return ret;
188}
189
190asmlinkage int solaris_fxstat(int vers, u32 fd, u32 statbuf)
191{
192 return solaris_fstat(fd, statbuf);
193}
194
195asmlinkage int solaris_fstat64(unsigned int fd, u32 statbuf)
196{
197 struct kstat s;
198 int ret = vfs_fstat(fd, &s);
199 if (!ret)
200 return putstat64(A(statbuf), &s);
201 return ret;
202}
203
204asmlinkage int solaris_mknod(u32 path, u32 mode, s32 dev)
205{
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);
210
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)));
215}
216
217asmlinkage int solaris_xmknod(int vers, u32 path, u32 mode, s32 dev)
218{
219 return solaris_mknod(path, mode, dev);
220}
221
222asmlinkage int solaris_getdents64(unsigned int fd, void __user *dirent, unsigned int count)
223{
224 int (*sys_getdents)(unsigned int, void __user *, unsigned int) =
225 (int (*)(unsigned int, void __user *, unsigned int))SYS(getdents);
226
227 return sys_getdents(fd, dirent, count);
228}
229
230/* This statfs thingie probably will go in the near future, but... */
231
232struct 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];
242};
243
244asmlinkage int solaris_statfs(u32 path, u32 buf, int len, int fstype)
245{
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);
252
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;
269 }
270 return ret;
271 }
272/* Linux can't stat unmounted filesystems so we
273 * simply lie and claim 100MB of 1GB is free. Sorry.
274 */
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;
285}
286
287asmlinkage int solaris_fstatfs(u32 fd, u32 buf, int len, int fstype)
288{
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);
295
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;
311 }
312 return ret;
313 }
314 /* Otherwise fstatfs is the same as statfs */
315 return solaris_statfs(0, buf, len, fstype);
316}
317
318struct 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];
333};
334
335struct 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];
350};
351
352static int report_statvfs(struct vfsmount *mnt, struct inode *inode, u32 buf)
353{
354 struct kstatfs s;
355 int error;
356 struct sol_statvfs __user *ss = A(buf);
357
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);
363
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;
384 }
385 return error;
386}
387
388static int report_statvfs64(struct vfsmount *mnt, struct inode *inode, u32 buf)
389{
390 struct kstatfs s;
391 int error;
392 struct sol_statvfs64 __user *ss = A(buf);
393
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);
399
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;
420 }
421 return error;
422}
423
424asmlinkage int solaris_statvfs(u32 path, u32 buf)
425{
426 struct nameidata nd;
427 int error;
428
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);
434 }
435 return error;
436}
437
438asmlinkage int solaris_fstatvfs(unsigned int fd, u32 buf)
439{
440 struct file * file;
441 int error;
442
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);
448 }
449
450 return error;
451}
452
453asmlinkage int solaris_statvfs64(u32 path, u32 buf)
454{
455 struct nameidata nd;
456 int error;
457
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);
464 }
465 unlock_kernel();
466 return error;
467}
468
469asmlinkage int solaris_fstatvfs64(unsigned int fd, u32 buf)
470{
471 struct file * file;
472 int error;
473
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);
481 }
482 return error;
483}
484
485extern asmlinkage long sparc32_open(const char * filename, int flags, int mode);
486
487asmlinkage int solaris_open(u32 fname, int flags, u32 mode)
488{
489 const char *filename = (const char *)(long)fname;
490 int fl = flags & 0xf;
491
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;
501
502 return sparc32_open(filename, flags, mode);
503}
504
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
517
518struct 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];
526};
527
528asmlinkage int solaris_fcntl(unsigned fd, unsigned cmd, u32 arg)
529{
530 int (*sys_fcntl)(unsigned,unsigned,unsigned long) =
531 (int (*)(unsigned,unsigned,unsigned long))SYS(fcntl);
532 int ret, flags;
533
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:
552 {
553 struct flock f;
554 struct sol_flock __user *p = A(arg);
555 mm_segment_t old_fs = get_fs();
556
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;
561 }
562
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;
569
570 set_fs(KERNEL_DS);
571 ret = sys_fcntl(fd, cmd, (unsigned long)&f);
572 set_fs(old_fs);
573
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;
581
582 return ret;
583 }
584 case SOL_F_FREESP:
585 {
586 int length;
587 int (*sys_newftruncate)(unsigned int, unsigned long)=
588 (int (*)(unsigned int, unsigned long))SYS(ftruncate);
589
590 if (get_user(length, &((struct sol_flock __user *)A(arg))->l_start))
591 return -EFAULT;
592
593 return sys_newftruncate(fd, length);
594 }
595 };
596 return -EINVAL;
597}
598
599asmlinkage int solaris_ulimit(int cmd, int val)
600{
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;
612 }
613 current->signal->rlim[RLIMIT_FSIZE].rlim_max = val;
614 }
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;
622 }
623 return -EINVAL;
624}
625
626/* At least at the time I'm writing this, Linux doesn't have ACLs, so we
627 just fake this */
628asmlinkage int solaris_acl(u32 filename, int cmd, int nentries, u32 aclbufp)
629{
630 return -ENOSYS;
631}
632
633asmlinkage int solaris_facl(unsigned int fd, int cmd, int nentries, u32 aclbufp)
634{
635 return -ENOSYS;
636}
637
638asmlinkage int solaris_pread(unsigned int fd, char __user *buf, u32 count, u32 pos)
639{
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);
642
643 return sys_pread64(fd, buf, count, (loff_t)pos);
644}
645
646asmlinkage int solaris_pwrite(unsigned int fd, char __user *buf, u32 count, u32 pos)
647{
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);
650
651 return sys_pwrite64(fd, buf, count, (loff_t)pos);
652}
653
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
669
670/* This is not a real and complete implementation yet, just to keep
671 * the easy Solaris binaries happy.
672 */
673asmlinkage int solaris_fpathconf(int fd, int name)
674{
675 int ret;
676
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;
706 }
707 return ret;
708}
709
710asmlinkage int solaris_pathconf(u32 path, int name)
711{
712 return solaris_fpathconf(0, name);
713}
714
715/* solaris_llseek returns long long - quite difficult */
716asmlinkage long solaris_llseek(struct pt_regs *regs, u32 off_hi, u32 off_lo, int whence)
717{
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;
723
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);
730}
731
732/* Have to mask out all but lower 3 bits */
733asmlinkage int solaris_access(u32 filename, long mode)
734{
735 int (*sys_access)(const char __user *, int) =
736 (int (*)(const char __user *, int))SYS(access);
737
738 return sys_access(A(filename), mode & 7);
739}