pass a struct path to vfs_statfs
[linux-2.6.git] / arch / parisc / hpux / sys_hpux.c
1 /*
2  *    Implements HPUX syscalls.
3  *
4  *    Copyright (C) 1999 Matthew Wilcox <willy with parisc-linux.org>
5  *    Copyright (C) 2000 Philipp Rumpf
6  *    Copyright (C) 2000 John Marvin <jsm with parisc-linux.org>
7  *    Copyright (C) 2000 Michael Ang <mang with subcarrier.org>
8  *    Copyright (C) 2001 Nathan Neulinger <nneul at umr.edu>
9  *
10  *    This program is free software; you can redistribute it and/or modify
11  *    it under the terms of the GNU General Public License as published by
12  *    the Free Software Foundation; either version 2 of the License, or
13  *    (at your option) any later version.
14  *
15  *    This program is distributed in the hope that it will be useful,
16  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *    GNU General Public License for more details.
19  *
20  *    You should have received a copy of the GNU General Public License
21  *    along with this program; if not, write to the Free Software
22  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  */
24
25 #include <linux/capability.h>
26 #include <linux/file.h>
27 #include <linux/fs.h>
28 #include <linux/namei.h>
29 #include <linux/sched.h>
30 #include <linux/slab.h>
31 #include <linux/smp_lock.h>
32 #include <linux/syscalls.h>
33 #include <linux/utsname.h>
34 #include <linux/vfs.h>
35 #include <linux/vmalloc.h>
36
37 #include <asm/errno.h>
38 #include <asm/pgalloc.h>
39 #include <asm/uaccess.h>
40
41 unsigned long hpux_brk(unsigned long addr)
42 {
43         /* Sigh.  Looks like HP/UX libc relies on kernel bugs. */
44         return sys_brk(addr + PAGE_SIZE);
45 }
46
47 int hpux_sbrk(void)
48 {
49         return -ENOSYS;
50 }
51
52 /* Random other syscalls */
53
54 int hpux_nice(int priority_change)
55 {
56         return -ENOSYS;
57 }
58
59 int hpux_ptrace(void)
60 {
61         return -ENOSYS;
62 }
63
64 int hpux_wait(int __user *stat_loc)
65 {
66         return sys_waitpid(-1, stat_loc, 0);
67 }
68
69 int hpux_setpgrp(void)
70 {
71         return sys_setpgid(0,0);
72 }
73
74 int hpux_setpgrp3(void)
75 {
76         return hpux_setpgrp();
77 }
78
79 #define _SC_CPU_VERSION 10001
80 #define _SC_OPEN_MAX    4
81 #define CPU_PA_RISC1_1  0x210
82
83 int hpux_sysconf(int which)
84 {
85         switch (which) {
86         case _SC_CPU_VERSION:
87                 return CPU_PA_RISC1_1;
88         case _SC_OPEN_MAX:
89                 return INT_MAX;
90         default:
91                 return -EINVAL;
92         }
93 }
94
95 /*****************************************************************************/
96
97 #define HPUX_UTSLEN 9
98 #define HPUX_SNLEN 15
99
100 struct hpux_utsname {
101         char sysname[HPUX_UTSLEN];
102         char nodename[HPUX_UTSLEN];
103         char release[HPUX_UTSLEN];
104         char version[HPUX_UTSLEN];
105         char machine[HPUX_UTSLEN];
106         char idnumber[HPUX_SNLEN];
107 } ;
108
109 struct hpux_ustat {
110         int32_t         f_tfree;        /* total free (daddr_t)  */
111         u_int32_t       f_tinode;       /* total inodes free (ino_t)  */
112         char            f_fname[6];     /* filsys name */
113         char            f_fpack[6];     /* filsys pack name */
114         u_int32_t       f_blksize;      /* filsys block size (int) */
115 };
116
117 /*
118  * HPUX's utssys() call.  It's a collection of miscellaneous functions,
119  * alas, so there's no nice way of splitting them up.
120  */
121
122 /*  This function is called from hpux_utssys(); HP-UX implements
123  *  ustat() as an option to utssys().
124  *
125  *  Now, struct ustat on HP-UX is exactly the same as on Linux, except
126  *  that it contains one addition field on the end, int32_t f_blksize.
127  *  So, we could have written this function to just call the Linux
128  *  sys_ustat(), (defined in linux/fs/super.c), and then just
129  *  added this additional field to the user's structure.  But I figure
130  *  if we're gonna be digging through filesystem structures to get
131  *  this, we might as well just do the whole enchilada all in one go.
132  *
133  *  So, most of this function is almost identical to sys_ustat().
134  *  I have placed comments at the few lines changed or added, to
135  *  aid in porting forward if and when sys_ustat() is changed from
136  *  its form in kernel 2.2.5.
137  */
138 static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf)
139 {
140         struct super_block *s;
141         struct hpux_ustat tmp;  /* Changed to hpux_ustat */
142         struct kstatfs sbuf;
143         int err = -EINVAL;
144
145         s = user_get_super(dev);
146         if (s == NULL)
147                 goto out;
148         err = statfs_by_dentry(s->s_root, &sbuf);
149         drop_super(s);
150         if (err)
151                 goto out;
152
153         memset(&tmp,0,sizeof(tmp));
154
155         tmp.f_tfree = (int32_t)sbuf.f_bfree;
156         tmp.f_tinode = (u_int32_t)sbuf.f_ffree;
157         tmp.f_blksize = (u_int32_t)sbuf.f_bsize;  /*  Added this line  */
158
159         err = copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
160 out:
161         return err;
162 }
163
164 /*
165  * Wrapper for hpux statfs call. At the moment, just calls the linux native one
166  * and ignores the extra fields at the end of the hpux statfs struct.
167  *
168  */
169
170 typedef int32_t hpux_fsid_t[2];              /* file system ID type */
171 typedef uint16_t hpux_site_t;
172
173 struct hpux_statfs {
174      int32_t f_type;                    /* type of info, zero for now */
175      int32_t f_bsize;                   /* fundamental file system block size */
176      int32_t f_blocks;                  /* total blocks in file system */
177      int32_t f_bfree;                   /* free block in fs */
178      int32_t f_bavail;                  /* free blocks avail to non-superuser */
179      int32_t f_files;                   /* total file nodes in file system */
180      int32_t f_ffree;                   /* free file nodes in fs */
181      hpux_fsid_t  f_fsid;                    /* file system ID */
182      int32_t f_magic;                   /* file system magic number */
183      int32_t f_featurebits;             /* file system features */
184      int32_t f_spare[4];                /* spare for later */
185      hpux_site_t  f_cnode;                   /* cluster node where mounted */
186      int16_t f_pad;
187 };
188
189 static int do_statfs_hpux(struct path *path, struct hpux_statfs *buf)
190 {
191         struct kstatfs st;
192         int retval;
193         
194         retval = vfs_statfs(path, &st);
195         if (retval)
196                 return retval;
197
198         memset(buf, 0, sizeof(*buf));
199         buf->f_type = st.f_type;
200         buf->f_bsize = st.f_bsize;
201         buf->f_blocks = st.f_blocks;
202         buf->f_bfree = st.f_bfree;
203         buf->f_bavail = st.f_bavail;
204         buf->f_files = st.f_files;
205         buf->f_ffree = st.f_ffree;
206         buf->f_fsid[0] = st.f_fsid.val[0];
207         buf->f_fsid[1] = st.f_fsid.val[1];
208
209         return 0;
210 }
211
212 /* hpux statfs */
213 asmlinkage long hpux_statfs(const char __user *pathname,
214                                                 struct hpux_statfs __user *buf)
215 {
216         struct path path;
217         int error;
218
219         error = user_path(pathname, &path);
220         if (!error) {
221                 struct hpux_statfs tmp;
222                 error = do_statfs_hpux(&path, &tmp);
223                 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
224                         error = -EFAULT;
225                 path_put(&path);
226         }
227         return error;
228 }
229
230 asmlinkage long hpux_fstatfs(unsigned int fd, struct hpux_statfs __user * buf)
231 {
232         struct file *file;
233         struct hpux_statfs tmp;
234         int error;
235
236         error = -EBADF;
237         file = fget(fd);
238         if (!file)
239                 goto out;
240         error = do_statfs_hpux(&file->f_path, &tmp);
241         if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
242                 error = -EFAULT;
243         fput(file);
244  out:
245         return error;
246 }
247
248
249 /*  This function is called from hpux_utssys(); HP-UX implements
250  *  uname() as an option to utssys().
251  *
252  *  The form of this function is pretty much copied from sys_olduname(),
253  *  defined in linux/arch/i386/kernel/sys_i386.c.
254  */
255 /*  TODO: Are these put_user calls OK?  Should they pass an int?
256  *        (I copied it from sys_i386.c like this.)
257  */
258 static int hpux_uname(struct hpux_utsname __user *name)
259 {
260         int error;
261
262         if (!name)
263                 return -EFAULT;
264         if (!access_ok(VERIFY_WRITE,name,sizeof(struct hpux_utsname)))
265                 return -EFAULT;
266
267         down_read(&uts_sem);
268
269         error = __copy_to_user(&name->sysname, &utsname()->sysname,
270                                HPUX_UTSLEN - 1);
271         error |= __put_user(0, name->sysname + HPUX_UTSLEN - 1);
272         error |= __copy_to_user(&name->nodename, &utsname()->nodename,
273                                 HPUX_UTSLEN - 1);
274         error |= __put_user(0, name->nodename + HPUX_UTSLEN - 1);
275         error |= __copy_to_user(&name->release, &utsname()->release,
276                                 HPUX_UTSLEN - 1);
277         error |= __put_user(0, name->release + HPUX_UTSLEN - 1);
278         error |= __copy_to_user(&name->version, &utsname()->version,
279                                 HPUX_UTSLEN - 1);
280         error |= __put_user(0, name->version + HPUX_UTSLEN - 1);
281         error |= __copy_to_user(&name->machine, &utsname()->machine,
282                                 HPUX_UTSLEN - 1);
283         error |= __put_user(0, name->machine + HPUX_UTSLEN - 1);
284
285         up_read(&uts_sem);
286
287         /*  HP-UX  utsname has no domainname field.  */
288
289         /*  TODO:  Implement idnumber!!!  */
290 #if 0
291         error |= __put_user(0,name->idnumber);
292         error |= __put_user(0,name->idnumber+HPUX_SNLEN-1);
293 #endif
294
295         error = error ? -EFAULT : 0;
296
297         return error;
298 }
299
300 /*  Note: HP-UX just uses the old suser() function to check perms
301  *  in this system call.  We'll use capable(CAP_SYS_ADMIN).
302  */
303 int hpux_utssys(char __user *ubuf, int n, int type)
304 {
305         int len;
306         int error;
307         switch( type ) {
308         case 0:
309                 /*  uname():  */
310                 return hpux_uname((struct hpux_utsname __user *)ubuf);
311                 break ;
312         case 1:
313                 /*  Obsolete (used to be umask().)  */
314                 return -EFAULT ;
315                 break ;
316         case 2:
317                 /*  ustat():  */
318                 return hpux_ustat(new_decode_dev(n),
319                                   (struct hpux_ustat __user *)ubuf);
320                 break;
321         case 3:
322                 /*  setuname():
323                  *
324                  *  On linux (unlike HP-UX), utsname.nodename
325                  *  is the same as the hostname.
326                  *
327                  *  sys_sethostname() is defined in linux/kernel/sys.c.
328                  */
329                 if (!capable(CAP_SYS_ADMIN))
330                         return -EPERM;
331                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
332                 if ( n <= 0 )
333                         return -EINVAL ;
334                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
335                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
336                 return sys_sethostname(ubuf, len);
337                 break ;
338         case 4:
339                 /*  sethostname():
340                  *
341                  *  sys_sethostname() is defined in linux/kernel/sys.c.
342                  */
343                 if (!capable(CAP_SYS_ADMIN))
344                         return -EPERM;
345                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
346                 if ( n <= 0 )
347                         return -EINVAL ;
348                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
349                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
350                 return sys_sethostname(ubuf, len);
351                 break ;
352         case 5:
353                 /*  gethostname():
354                  *
355                  *  sys_gethostname() is defined in linux/kernel/sys.c.
356                  */
357                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
358                 if ( n <= 0 )
359                         return -EINVAL ;
360                 return sys_gethostname(ubuf, n);
361                 break ;
362         case 6:
363                 /*  Supposedly called from setuname() in libc.
364                  *  TODO: When and why is this called?
365                  *        Is it ever even called?
366                  *
367                  *  This code should look a lot like sys_sethostname(),
368                  *  defined in linux/kernel/sys.c.  If that gets updated,
369                  *  update this code similarly.
370                  */
371                 if (!capable(CAP_SYS_ADMIN))
372                         return -EPERM;
373                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
374                 if ( n <= 0 )
375                         return -EINVAL ;
376                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
377                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
378                 /**/
379                 /*  TODO:  print a warning about using this?  */
380                 down_write(&uts_sem);
381                 error = -EFAULT;
382                 if (!copy_from_user(utsname()->sysname, ubuf, len)) {
383                         utsname()->sysname[len] = 0;
384                         error = 0;
385                 }
386                 up_write(&uts_sem);
387                 return error;
388                 break ;
389         case 7:
390                 /*  Sets utsname.release, if you're allowed.
391                  *  Undocumented.  Used by swinstall to change the
392                  *  OS version, during OS updates.  Yuck!!!
393                  *
394                  *  This code should look a lot like sys_sethostname()
395                  *  in linux/kernel/sys.c.  If that gets updated, update
396                  *  this code similarly.
397                  */
398                 if (!capable(CAP_SYS_ADMIN))
399                         return -EPERM;
400                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
401                 if ( n <= 0 )
402                         return -EINVAL ;
403                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
404                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
405                 /**/
406                 /*  TODO:  print a warning about this?  */
407                 down_write(&uts_sem);
408                 error = -EFAULT;
409                 if (!copy_from_user(utsname()->release, ubuf, len)) {
410                         utsname()->release[len] = 0;
411                         error = 0;
412                 }
413                 up_write(&uts_sem);
414                 return error;
415                 break ;
416         default:
417                 /*  This system call returns -EFAULT if given an unknown type.
418                  *  Why not -EINVAL?  I don't know, it's just not what they did.
419                  */
420                 return -EFAULT ;
421         }
422 }
423
424 int hpux_getdomainname(char __user *name, int len)
425 {
426         int nlen;
427         int err = -EFAULT;
428         
429         down_read(&uts_sem);
430         
431         nlen = strlen(utsname()->domainname) + 1;
432
433         if (nlen < len)
434                 len = nlen;
435         if(len > __NEW_UTS_LEN)
436                 goto done;
437         if(copy_to_user(name, utsname()->domainname, len))
438                 goto done;
439         err = 0;
440 done:
441         up_read(&uts_sem);
442         return err;
443         
444 }
445
446 int hpux_pipe(int *kstack_fildes)
447 {
448         return do_pipe_flags(kstack_fildes, 0);
449 }
450
451 /* lies - says it works, but it really didn't lock anything */
452 int hpux_lockf(int fildes, int function, off_t size)
453 {
454         return 0;
455 }
456
457 int hpux_sysfs(int opcode, unsigned long arg1, unsigned long arg2)
458 {
459         char *fsname = NULL;
460         int len = 0;
461         int fstype;
462
463 /*Unimplemented HP-UX syscall emulation. Syscall #334 (sysfs)
464   Args: 1 80057bf4 0 400179f0 0 0 0 */
465         printk(KERN_DEBUG "in hpux_sysfs\n");
466         printk(KERN_DEBUG "hpux_sysfs called with opcode = %d\n", opcode);
467         printk(KERN_DEBUG "hpux_sysfs called with arg1='%lx'\n", arg1);
468
469         if ( opcode == 1 ) { /* GETFSIND */     
470                 char __user *user_fsname = (char __user *)arg1;
471                 len = strlen_user(user_fsname);
472                 printk(KERN_DEBUG "len of arg1 = %d\n", len);
473                 if (len == 0)
474                         return 0;
475                 fsname = kmalloc(len, GFP_KERNEL);
476                 if (!fsname) {
477                         printk(KERN_DEBUG "failed to kmalloc fsname\n");
478                         return 0;
479                 }
480
481                 if (copy_from_user(fsname, user_fsname, len)) {
482                         printk(KERN_DEBUG "failed to copy_from_user fsname\n");
483                         kfree(fsname);
484                         return 0;
485                 }
486
487                 /* String could be altered by userspace after strlen_user() */
488                 fsname[len] = '\0';
489
490                 printk(KERN_DEBUG "that is '%s' as (char *)\n", fsname);
491                 if ( !strcmp(fsname, "hfs") ) {
492                         fstype = 0;
493                 } else {
494                         fstype = 0;
495                 }
496
497                 kfree(fsname);
498
499                 printk(KERN_DEBUG "returning fstype=%d\n", fstype);
500                 return fstype; /* something other than default */
501         }
502
503
504         return 0;
505 }
506
507
508 /* Table of syscall names and handle for unimplemented routines */
509 static const char * const syscall_names[] = {
510         "nosys",                  /* 0 */
511         "exit",                  
512         "fork",                  
513         "read",                  
514         "write",                 
515         "open",                   /* 5 */
516         "close",                 
517         "wait",                  
518         "creat",                 
519         "link",                  
520         "unlink",                 /* 10 */
521         "execv",                 
522         "chdir",                 
523         "time",                  
524         "mknod",                 
525         "chmod",                  /* 15 */
526         "chown",                 
527         "brk",                   
528         "lchmod",                
529         "lseek",                 
530         "getpid",                 /* 20 */
531         "mount",                 
532         "umount",                
533         "setuid",                
534         "getuid",                
535         "stime",                  /* 25 */
536         "ptrace",                
537         "alarm",                 
538         NULL,                    
539         "pause",                 
540         "utime",                  /* 30 */
541         "stty",                  
542         "gtty",                  
543         "access",                
544         "nice",                  
545         "ftime",                  /* 35 */
546         "sync",                  
547         "kill",                  
548         "stat",                  
549         "setpgrp3",              
550         "lstat",                  /* 40 */
551         "dup",                   
552         "pipe",                  
553         "times",                 
554         "profil",                
555         "ki_call",                /* 45 */
556         "setgid",                
557         "getgid",                
558         NULL,                    
559         NULL,                    
560         NULL,                     /* 50 */
561         "acct",                  
562         "set_userthreadid",      
563         NULL,                    
564         "ioctl",                 
565         "reboot",                 /* 55 */
566         "symlink",               
567         "utssys",                
568         "readlink",              
569         "execve",                
570         "umask",                  /* 60 */
571         "chroot",                
572         "fcntl",                 
573         "ulimit",                
574         NULL,                    
575         NULL,                     /* 65 */
576         "vfork",                 
577         NULL,                    
578         NULL,                    
579         NULL,                    
580         NULL,                     /* 70 */
581         "mmap",                  
582         NULL,                    
583         "munmap",                
584         "mprotect",              
585         "madvise",                /* 75 */
586         "vhangup",               
587         "swapoff",               
588         NULL,                    
589         "getgroups",             
590         "setgroups",              /* 80 */
591         "getpgrp2",              
592         "setpgid/setpgrp2",      
593         "setitimer",             
594         "wait3",                 
595         "swapon",                 /* 85 */
596         "getitimer",             
597         NULL,                    
598         NULL,                    
599         NULL,                    
600         "dup2",                   /* 90 */
601         NULL,                    
602         "fstat",                 
603         "select",                
604         NULL,                    
605         "fsync",                  /* 95 */
606         "setpriority",           
607         NULL,                    
608         NULL,                    
609         NULL,                    
610         "getpriority",            /* 100 */
611         NULL,                    
612         NULL,                    
613         NULL,                    
614         NULL,                    
615         NULL,                     /* 105 */
616         NULL,                    
617         NULL,                    
618         "sigvector",             
619         "sigblock",              
620         "sigsetmask",             /* 110 */
621         "sigpause",              
622         "sigstack",              
623         NULL,                    
624         NULL,                    
625         NULL,                     /* 115 */
626         "gettimeofday",          
627         "getrusage",             
628         NULL,                    
629         NULL,                    
630         "readv",                  /* 120 */
631         "writev",                
632         "settimeofday",          
633         "fchown",                
634         "fchmod",                
635         NULL,                     /* 125 */
636         "setresuid",             
637         "setresgid",             
638         "rename",                
639         "truncate",              
640         "ftruncate",              /* 130 */
641         NULL,                    
642         "sysconf",               
643         NULL,                    
644         NULL,                    
645         NULL,                     /* 135 */
646         "mkdir",                 
647         "rmdir",                 
648         NULL,                    
649         "sigcleanup",            
650         "setcore",                /* 140 */
651         NULL,                    
652         "gethostid",             
653         "sethostid",             
654         "getrlimit",             
655         "setrlimit",              /* 145 */
656         NULL,                    
657         NULL,                    
658         "quotactl",              
659         "get_sysinfo",           
660         NULL,                     /* 150 */
661         "privgrp",               
662         "rtprio",                
663         "plock",                 
664         NULL,                    
665         "lockf",                  /* 155 */
666         "semget",                
667         NULL,                    
668         "semop",                 
669         "msgget",                
670         NULL,                     /* 160 */
671         "msgsnd",                
672         "msgrcv",                
673         "shmget",                
674         NULL,                    
675         "shmat",                  /* 165 */
676         "shmdt",                 
677         NULL,                    
678         "csp/nsp_init",          
679         "cluster",               
680         "mkrnod",                 /* 170 */
681         "test",                  
682         "unsp_open",             
683         NULL,                    
684         "getcontext",            
685         "osetcontext",            /* 175 */
686         "bigio",                 
687         "pipenode",              
688         "lsync",                 
689         "getmachineid",          
690         "cnodeid/mysite",         /* 180 */
691         "cnodes/sitels",         
692         "swapclients",           
693         "rmtprocess",            
694         "dskless_stats",         
695         "sigprocmask",            /* 185 */
696         "sigpending",            
697         "sigsuspend",            
698         "sigaction",             
699         NULL,                    
700         "nfssvc",                 /* 190 */
701         "getfh",                 
702         "getdomainname",         
703         "setdomainname",         
704         "async_daemon",          
705         "getdirentries",          /* 195 */
706         NULL,                
707         NULL,               
708         "vfsmount",              
709         NULL,                    
710         "waitpid",                /* 200 */
711         NULL,                    
712         NULL,                    
713         NULL,                    
714         NULL,                    
715         NULL,                     /* 205 */
716         NULL,                    
717         NULL,                    
718         NULL,                    
719         NULL,                    
720         NULL,                     /* 210 */
721         NULL,                    
722         NULL,                    
723         NULL,                    
724         NULL,                    
725         NULL,                     /* 215 */
726         NULL,                    
727         NULL,                    
728         NULL,                    
729         NULL,                    
730         NULL,                     /* 220 */
731         NULL,                    
732         NULL,                    
733         NULL,                    
734         "sigsetreturn",          
735         "sigsetstatemask",        /* 225 */
736         "bfactl",                
737         "cs",                    
738         "cds",                   
739         NULL,                    
740         "pathconf",               /* 230 */
741         "fpathconf",             
742         NULL,                    
743         NULL,                    
744         "nfs_fcntl",             
745         "ogetacl",                /* 235 */
746         "ofgetacl",              
747         "osetacl",               
748         "ofsetacl",              
749         "pstat",                 
750         "getaudid",               /* 240 */
751         "setaudid",              
752         "getaudproc",            
753         "setaudproc",            
754         "getevent",              
755         "setevent",               /* 245 */
756         "audwrite",              
757         "audswitch",             
758         "audctl",                
759         "ogetaccess",            
760         "fsctl",                  /* 250 */
761         "ulconnect",             
762         "ulcontrol",             
763         "ulcreate",              
764         "uldest",                
765         "ulrecv",                 /* 255 */
766         "ulrecvcn",              
767         "ulsend",                
768         "ulshutdown",            
769         "swapfs",                
770         "fss",                    /* 260 */
771         NULL,                    
772         NULL,                    
773         NULL,                    
774         NULL,                    
775         NULL,                     /* 265 */
776         NULL,                    
777         "tsync",                 
778         "getnumfds",             
779         "poll",                  
780         "getmsg",                 /* 270 */
781         "putmsg",                
782         "fchdir",                
783         "getmount_cnt",          
784         "getmount_entry",        
785         "accept",                 /* 275 */
786         "bind",                  
787         "connect",               
788         "getpeername",           
789         "getsockname",           
790         "getsockopt",             /* 280 */
791         "listen",                
792         "recv",                  
793         "recvfrom",              
794         "recvmsg",               
795         "send",                   /* 285 */
796         "sendmsg",               
797         "sendto",                
798         "setsockopt",            
799         "shutdown",              
800         "socket",                 /* 290 */
801         "socketpair",            
802         "proc_open",             
803         "proc_close",            
804         "proc_send",             
805         "proc_recv",              /* 295 */
806         "proc_sendrecv",         
807         "proc_syscall",          
808         "ipccreate",             
809         "ipcname",               
810         "ipcnamerase",            /* 300 */
811         "ipclookup",             
812         "ipcselect",             
813         "ipcconnect",            
814         "ipcrecvcn",             
815         "ipcsend",                /* 305 */
816         "ipcrecv",               
817         "ipcgetnodename",        
818         "ipcsetnodename",        
819         "ipccontrol",            
820         "ipcshutdown",            /* 310 */
821         "ipcdest",               
822         "semctl",                
823         "msgctl",                
824         "shmctl",                
825         "mpctl",                  /* 315 */
826         "exportfs",              
827         "getpmsg",               
828         "putpmsg",               
829         "strioctl",              
830         "msync",                  /* 320 */
831         "msleep",                
832         "mwakeup",               
833         "msem_init",             
834         "msem_remove",           
835         "adjtime",                /* 325 */
836         "kload",                 
837         "fattach",               
838         "fdetach",               
839         "serialize",             
840         "statvfs",                /* 330 */
841         "fstatvfs",              
842         "lchown",                
843         "getsid",                
844         "sysfs",                 
845         NULL,                     /* 335 */
846         NULL,                    
847         "sched_setparam",        
848         "sched_getparam",        
849         "sched_setscheduler",    
850         "sched_getscheduler",     /* 340 */
851         "sched_yield",           
852         "sched_get_priority_max",
853         "sched_get_priority_min",
854         "sched_rr_get_interval", 
855         "clock_settime",          /* 345 */
856         "clock_gettime",         
857         "clock_getres",          
858         "timer_create",          
859         "timer_delete",          
860         "timer_settime",          /* 350 */
861         "timer_gettime",         
862         "timer_getoverrun",      
863         "nanosleep",             
864         "toolbox",               
865         NULL,                     /* 355 */
866         "getdents",              
867         "getcontext",            
868         "sysinfo",               
869         "fcntl64",               
870         "ftruncate64",            /* 360 */
871         "fstat64",               
872         "getdirentries64",       
873         "getrlimit64",           
874         "lockf64",               
875         "lseek64",                /* 365 */
876         "lstat64",               
877         "mmap64",                
878         "setrlimit64",           
879         "stat64",                
880         "truncate64",             /* 370 */
881         "ulimit64",              
882         NULL,                    
883         NULL,                    
884         NULL,                    
885         NULL,                     /* 375 */
886         NULL,                    
887         NULL,                    
888         NULL,                    
889         NULL,                    
890         "setcontext",             /* 380 */
891         "sigaltstack",           
892         "waitid",                
893         "setpgrp",               
894         "recvmsg2",              
895         "sendmsg2",               /* 385 */
896         "socket2",               
897         "socketpair2",           
898         "setregid",              
899         "lwp_create",            
900         "lwp_terminate",          /* 390 */
901         "lwp_wait",              
902         "lwp_suspend",           
903         "lwp_resume",            
904         "lwp_self",              
905         "lwp_abort_syscall",      /* 395 */
906         "lwp_info",              
907         "lwp_kill",              
908         "ksleep",                
909         "kwakeup",               
910         "ksleep_abort",           /* 400 */
911         "lwp_proc_info",         
912         "lwp_exit",              
913         "lwp_continue",          
914         "getacl",                
915         "fgetacl",                /* 405 */
916         "setacl",                
917         "fsetacl",               
918         "getaccess",             
919         "lwp_mutex_init",        
920         "lwp_mutex_lock_sys",     /* 410 */
921         "lwp_mutex_unlock",      
922         "lwp_cond_init",         
923         "lwp_cond_signal",       
924         "lwp_cond_broadcast",    
925         "lwp_cond_wait_sys",      /* 415 */
926         "lwp_getscheduler",      
927         "lwp_setscheduler",      
928         "lwp_getprivate",        
929         "lwp_setprivate",        
930         "lwp_detach",             /* 420 */
931         "mlock",                 
932         "munlock",               
933         "mlockall",              
934         "munlockall",            
935         "shm_open",               /* 425 */
936         "shm_unlink",            
937         "sigqueue",              
938         "sigwaitinfo",           
939         "sigtimedwait",          
940         "sigwait",                /* 430 */
941         "aio_read",              
942         "aio_write",             
943         "lio_listio",            
944         "aio_error",             
945         "aio_return",             /* 435 */
946         "aio_cancel",            
947         "aio_suspend",           
948         "aio_fsync",             
949         "mq_open",               
950         "mq_unlink",              /* 440 */
951         "mq_send",               
952         "mq_receive",            
953         "mq_notify",             
954         "mq_setattr",            
955         "mq_getattr",             /* 445 */
956         "ksem_open",             
957         "ksem_unlink",           
958         "ksem_close",            
959         "ksem_destroy",          
960         "lw_sem_incr",            /* 450 */
961         "lw_sem_decr",           
962         "lw_sem_read",           
963         "mq_close",              
964 };
965 static const int syscall_names_max = 453;
966
967 int
968 hpux_unimplemented(unsigned long arg1,unsigned long arg2,unsigned long arg3,
969                    unsigned long arg4,unsigned long arg5,unsigned long arg6,
970                    unsigned long arg7,unsigned long sc_num)
971 {
972         /* NOTE: sc_num trashes arg8 for the few syscalls that actually
973          * have a valid 8th argument.
974          */
975         const char *name = NULL;
976         if ( sc_num <= syscall_names_max && sc_num >= 0 ) {
977                 name = syscall_names[sc_num];
978         }
979
980         if ( name ) {
981                 printk(KERN_DEBUG "Unimplemented HP-UX syscall emulation. Syscall #%lu (%s)\n",
982                 sc_num, name);
983         } else {
984                 printk(KERN_DEBUG "Unimplemented unknown HP-UX syscall emulation. Syscall #%lu\n",
985                 sc_num);
986         }
987         
988         printk(KERN_DEBUG "  Args: %lx %lx %lx %lx %lx %lx %lx\n",
989                 arg1, arg2, arg3, arg4, arg5, arg6, arg7);
990
991         return -ENOSYS;
992 }