Merge branch 'upstream'
[pandora-kernel.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 *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 = vfs_statfs(s, &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 vfs_statfs_hpux(struct super_block *sb, struct hpux_statfs *buf)
190 {
191         struct kstatfs st;
192         int retval;
193         
194         retval = vfs_statfs(sb, &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 *path,
214                                                 struct hpux_statfs __user *buf)
215 {
216         struct nameidata nd;
217         int error;
218
219         error = user_path_walk(path, &nd);
220         if (!error) {
221                 struct hpux_statfs tmp;
222                 error = vfs_statfs_hpux(nd.dentry->d_inode->i_sb, &tmp);
223                 if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
224                         error = -EFAULT;
225                 path_release(&nd);
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 = vfs_statfs_hpux(file->f_dentry->d_inode->i_sb, &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 *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,&system_utsname.sysname,HPUX_UTSLEN-1);
270         error |= __put_user(0,name->sysname+HPUX_UTSLEN-1);
271         error |= __copy_to_user(&name->nodename,&system_utsname.nodename,HPUX_UTSLEN-1);
272         error |= __put_user(0,name->nodename+HPUX_UTSLEN-1);
273         error |= __copy_to_user(&name->release,&system_utsname.release,HPUX_UTSLEN-1);
274         error |= __put_user(0,name->release+HPUX_UTSLEN-1);
275         error |= __copy_to_user(&name->version,&system_utsname.version,HPUX_UTSLEN-1);
276         error |= __put_user(0,name->version+HPUX_UTSLEN-1);
277         error |= __copy_to_user(&name->machine,&system_utsname.machine,HPUX_UTSLEN-1);
278         error |= __put_user(0,name->machine+HPUX_UTSLEN-1);
279
280         up_read(&uts_sem);
281
282         /*  HP-UX  utsname has no domainname field.  */
283
284         /*  TODO:  Implement idnumber!!!  */
285 #if 0
286         error |= __put_user(0,name->idnumber);
287         error |= __put_user(0,name->idnumber+HPUX_SNLEN-1);
288 #endif
289
290         error = error ? -EFAULT : 0;
291
292         return error;
293 }
294
295 /*  Note: HP-UX just uses the old suser() function to check perms
296  *  in this system call.  We'll use capable(CAP_SYS_ADMIN).
297  */
298 int hpux_utssys(char *ubuf, int n, int type)
299 {
300         int len;
301         int error;
302         switch( type ) {
303         case 0:
304                 /*  uname():  */
305                 return( hpux_uname( (struct hpux_utsname *)ubuf ) );
306                 break ;
307         case 1:
308                 /*  Obsolete (used to be umask().)  */
309                 return -EFAULT ;
310                 break ;
311         case 2:
312                 /*  ustat():  */
313                 return( hpux_ustat(new_decode_dev(n), (struct hpux_ustat *)ubuf) );
314                 break ;
315         case 3:
316                 /*  setuname():
317                  *
318                  *  On linux (unlike HP-UX), utsname.nodename
319                  *  is the same as the hostname.
320                  *
321                  *  sys_sethostname() is defined in linux/kernel/sys.c.
322                  */
323                 if (!capable(CAP_SYS_ADMIN))
324                         return -EPERM;
325                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
326                 if ( n <= 0 )
327                         return -EINVAL ;
328                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
329                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
330                 return( sys_sethostname(ubuf, len) );
331                 break ;
332         case 4:
333                 /*  sethostname():
334                  *
335                  *  sys_sethostname() is defined in linux/kernel/sys.c.
336                  */
337                 if (!capable(CAP_SYS_ADMIN))
338                         return -EPERM;
339                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
340                 if ( n <= 0 )
341                         return -EINVAL ;
342                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
343                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
344                 return( sys_sethostname(ubuf, len) );
345                 break ;
346         case 5:
347                 /*  gethostname():
348                  *
349                  *  sys_gethostname() is defined in linux/kernel/sys.c.
350                  */
351                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
352                 if ( n <= 0 )
353                         return -EINVAL ;
354                 return( sys_gethostname(ubuf, n) );
355                 break ;
356         case 6:
357                 /*  Supposedly called from setuname() in libc.
358                  *  TODO: When and why is this called?
359                  *        Is it ever even called?
360                  *
361                  *  This code should look a lot like sys_sethostname(),
362                  *  defined in linux/kernel/sys.c.  If that gets updated,
363                  *  update this code similarly.
364                  */
365                 if (!capable(CAP_SYS_ADMIN))
366                         return -EPERM;
367                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
368                 if ( n <= 0 )
369                         return -EINVAL ;
370                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
371                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
372                 /**/
373                 /*  TODO:  print a warning about using this?  */
374                 down_write(&uts_sem);
375                 error = -EFAULT;
376                 if (!copy_from_user(system_utsname.sysname, ubuf, len)) {
377                         system_utsname.sysname[len] = 0;
378                         error = 0;
379                 }
380                 up_write(&uts_sem);
381                 return error;
382                 break ;
383         case 7:
384                 /*  Sets utsname.release, if you're allowed.
385                  *  Undocumented.  Used by swinstall to change the
386                  *  OS version, during OS updates.  Yuck!!!
387                  *
388                  *  This code should look a lot like sys_sethostname()
389                  *  in linux/kernel/sys.c.  If that gets updated, update
390                  *  this code similarly.
391                  */
392                 if (!capable(CAP_SYS_ADMIN))
393                         return -EPERM;
394                 /*  Unlike Linux, HP-UX returns an error if n==0:  */
395                 if ( n <= 0 )
396                         return -EINVAL ;
397                 /*  Unlike Linux, HP-UX truncates it if n is too big:  */
398                 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
399                 /**/
400                 /*  TODO:  print a warning about this?  */
401                 down_write(&uts_sem);
402                 error = -EFAULT;
403                 if (!copy_from_user(system_utsname.release, ubuf, len)) {
404                         system_utsname.release[len] = 0;
405                         error = 0;
406                 }
407                 up_write(&uts_sem);
408                 return error;
409                 break ;
410         default:
411                 /*  This system call returns -EFAULT if given an unknown type.
412                  *  Why not -EINVAL?  I don't know, it's just not what they did.
413                  */
414                 return -EFAULT ;
415         }
416 }
417
418 int hpux_getdomainname(char *name, int len)
419 {
420         int nlen;
421         int err = -EFAULT;
422         
423         down_read(&uts_sem);
424         
425         nlen = strlen(system_utsname.domainname) + 1;
426
427         if (nlen < len)
428                 len = nlen;
429         if(len > __NEW_UTS_LEN)
430                 goto done;
431         if(copy_to_user(name, system_utsname.domainname, len))
432                 goto done;
433         err = 0;
434 done:
435         up_read(&uts_sem);
436         return err;
437         
438 }
439
440 int hpux_pipe(int *kstack_fildes)
441 {
442         int error;
443
444         lock_kernel();
445         error = do_pipe(kstack_fildes);
446         unlock_kernel();
447         return error;
448 }
449
450 /* lies - says it works, but it really didn't lock anything */
451 int hpux_lockf(int fildes, int function, off_t size)
452 {
453         return 0;
454 }
455
456 int hpux_sysfs(int opcode, unsigned long arg1, unsigned long arg2)
457 {
458         char *fsname = NULL;
459         int len = 0;
460         int fstype;
461
462 /*Unimplemented HP-UX syscall emulation. Syscall #334 (sysfs)
463   Args: 1 80057bf4 0 400179f0 0 0 0 */
464         printk(KERN_DEBUG "in hpux_sysfs\n");
465         printk(KERN_DEBUG "hpux_sysfs called with opcode = %d\n", opcode);
466         printk(KERN_DEBUG "hpux_sysfs called with arg1='%lx'\n", arg1);
467
468         if ( opcode == 1 ) { /* GETFSIND */     
469                 len = strlen_user((char *)arg1);
470                 printk(KERN_DEBUG "len of arg1 = %d\n", len);
471
472                 fsname = (char *) kmalloc(len+1, GFP_KERNEL);
473                 if ( !fsname ) {
474                         printk(KERN_DEBUG "failed to kmalloc fsname\n");
475                         return 0;
476                 }
477
478                 if ( copy_from_user(fsname, (char *)arg1, len+1) ) {
479                         printk(KERN_DEBUG "failed to copy_from_user fsname\n");
480                         kfree(fsname);
481                         return 0;
482                 }
483
484                 printk(KERN_DEBUG "that is '%s' as (char *)\n", fsname);
485                 if ( !strcmp(fsname, "hfs") ) {
486                         fstype = 0;
487                 } else {
488                         fstype = 0;
489                 };
490
491                 kfree(fsname);
492
493                 printk(KERN_DEBUG "returning fstype=%d\n", fstype);
494                 return fstype; /* something other than default */
495         }
496
497
498         return 0;
499 }
500
501
502 /* Table of syscall names and handle for unimplemented routines */
503 static const char *syscall_names[] = {
504         "nosys",                  /* 0 */
505         "exit",                  
506         "fork",                  
507         "read",                  
508         "write",                 
509         "open",                   /* 5 */
510         "close",                 
511         "wait",                  
512         "creat",                 
513         "link",                  
514         "unlink",                 /* 10 */
515         "execv",                 
516         "chdir",                 
517         "time",                  
518         "mknod",                 
519         "chmod",                  /* 15 */
520         "chown",                 
521         "brk",                   
522         "lchmod",                
523         "lseek",                 
524         "getpid",                 /* 20 */
525         "mount",                 
526         "umount",                
527         "setuid",                
528         "getuid",                
529         "stime",                  /* 25 */
530         "ptrace",                
531         "alarm",                 
532         NULL,                    
533         "pause",                 
534         "utime",                  /* 30 */
535         "stty",                  
536         "gtty",                  
537         "access",                
538         "nice",                  
539         "ftime",                  /* 35 */
540         "sync",                  
541         "kill",                  
542         "stat",                  
543         "setpgrp3",              
544         "lstat",                  /* 40 */
545         "dup",                   
546         "pipe",                  
547         "times",                 
548         "profil",                
549         "ki_call",                /* 45 */
550         "setgid",                
551         "getgid",                
552         NULL,                    
553         NULL,                    
554         NULL,                     /* 50 */
555         "acct",                  
556         "set_userthreadid",      
557         NULL,                    
558         "ioctl",                 
559         "reboot",                 /* 55 */
560         "symlink",               
561         "utssys",                
562         "readlink",              
563         "execve",                
564         "umask",                  /* 60 */
565         "chroot",                
566         "fcntl",                 
567         "ulimit",                
568         NULL,                    
569         NULL,                     /* 65 */
570         "vfork",                 
571         NULL,                    
572         NULL,                    
573         NULL,                    
574         NULL,                     /* 70 */
575         "mmap",                  
576         NULL,                    
577         "munmap",                
578         "mprotect",              
579         "madvise",                /* 75 */
580         "vhangup",               
581         "swapoff",               
582         NULL,                    
583         "getgroups",             
584         "setgroups",              /* 80 */
585         "getpgrp2",              
586         "setpgid/setpgrp2",      
587         "setitimer",             
588         "wait3",                 
589         "swapon",                 /* 85 */
590         "getitimer",             
591         NULL,                    
592         NULL,                    
593         NULL,                    
594         "dup2",                   /* 90 */
595         NULL,                    
596         "fstat",                 
597         "select",                
598         NULL,                    
599         "fsync",                  /* 95 */
600         "setpriority",           
601         NULL,                    
602         NULL,                    
603         NULL,                    
604         "getpriority",            /* 100 */
605         NULL,                    
606         NULL,                    
607         NULL,                    
608         NULL,                    
609         NULL,                     /* 105 */
610         NULL,                    
611         NULL,                    
612         "sigvector",             
613         "sigblock",              
614         "sigsetmask",             /* 110 */
615         "sigpause",              
616         "sigstack",              
617         NULL,                    
618         NULL,                    
619         NULL,                     /* 115 */
620         "gettimeofday",          
621         "getrusage",             
622         NULL,                    
623         NULL,                    
624         "readv",                  /* 120 */
625         "writev",                
626         "settimeofday",          
627         "fchown",                
628         "fchmod",                
629         NULL,                     /* 125 */
630         "setresuid",             
631         "setresgid",             
632         "rename",                
633         "truncate",              
634         "ftruncate",              /* 130 */
635         NULL,                    
636         "sysconf",               
637         NULL,                    
638         NULL,                    
639         NULL,                     /* 135 */
640         "mkdir",                 
641         "rmdir",                 
642         NULL,                    
643         "sigcleanup",            
644         "setcore",                /* 140 */
645         NULL,                    
646         "gethostid",             
647         "sethostid",             
648         "getrlimit",             
649         "setrlimit",              /* 145 */
650         NULL,                    
651         NULL,                    
652         "quotactl",              
653         "get_sysinfo",           
654         NULL,                     /* 150 */
655         "privgrp",               
656         "rtprio",                
657         "plock",                 
658         NULL,                    
659         "lockf",                  /* 155 */
660         "semget",                
661         NULL,                    
662         "semop",                 
663         "msgget",                
664         NULL,                     /* 160 */
665         "msgsnd",                
666         "msgrcv",                
667         "shmget",                
668         NULL,                    
669         "shmat",                  /* 165 */
670         "shmdt",                 
671         NULL,                    
672         "csp/nsp_init",          
673         "cluster",               
674         "mkrnod",                 /* 170 */
675         "test",                  
676         "unsp_open",             
677         NULL,                    
678         "getcontext",            
679         "osetcontext",            /* 175 */
680         "bigio",                 
681         "pipenode",              
682         "lsync",                 
683         "getmachineid",          
684         "cnodeid/mysite",         /* 180 */
685         "cnodes/sitels",         
686         "swapclients",           
687         "rmtprocess",            
688         "dskless_stats",         
689         "sigprocmask",            /* 185 */
690         "sigpending",            
691         "sigsuspend",            
692         "sigaction",             
693         NULL,                    
694         "nfssvc",                 /* 190 */
695         "getfh",                 
696         "getdomainname",         
697         "setdomainname",         
698         "async_daemon",          
699         "getdirentries",          /* 195 */
700         NULL,                
701         NULL,               
702         "vfsmount",              
703         NULL,                    
704         "waitpid",                /* 200 */
705         NULL,                    
706         NULL,                    
707         NULL,                    
708         NULL,                    
709         NULL,                     /* 205 */
710         NULL,                    
711         NULL,                    
712         NULL,                    
713         NULL,                    
714         NULL,                     /* 210 */
715         NULL,                    
716         NULL,                    
717         NULL,                    
718         NULL,                    
719         NULL,                     /* 215 */
720         NULL,                    
721         NULL,                    
722         NULL,                    
723         NULL,                    
724         NULL,                     /* 220 */
725         NULL,                    
726         NULL,                    
727         NULL,                    
728         "sigsetreturn",          
729         "sigsetstatemask",        /* 225 */
730         "bfactl",                
731         "cs",                    
732         "cds",                   
733         NULL,                    
734         "pathconf",               /* 230 */
735         "fpathconf",             
736         NULL,                    
737         NULL,                    
738         "nfs_fcntl",             
739         "ogetacl",                /* 235 */
740         "ofgetacl",              
741         "osetacl",               
742         "ofsetacl",              
743         "pstat",                 
744         "getaudid",               /* 240 */
745         "setaudid",              
746         "getaudproc",            
747         "setaudproc",            
748         "getevent",              
749         "setevent",               /* 245 */
750         "audwrite",              
751         "audswitch",             
752         "audctl",                
753         "ogetaccess",            
754         "fsctl",                  /* 250 */
755         "ulconnect",             
756         "ulcontrol",             
757         "ulcreate",              
758         "uldest",                
759         "ulrecv",                 /* 255 */
760         "ulrecvcn",              
761         "ulsend",                
762         "ulshutdown",            
763         "swapfs",                
764         "fss",                    /* 260 */
765         NULL,                    
766         NULL,                    
767         NULL,                    
768         NULL,                    
769         NULL,                     /* 265 */
770         NULL,                    
771         "tsync",                 
772         "getnumfds",             
773         "poll",                  
774         "getmsg",                 /* 270 */
775         "putmsg",                
776         "fchdir",                
777         "getmount_cnt",          
778         "getmount_entry",        
779         "accept",                 /* 275 */
780         "bind",                  
781         "connect",               
782         "getpeername",           
783         "getsockname",           
784         "getsockopt",             /* 280 */
785         "listen",                
786         "recv",                  
787         "recvfrom",              
788         "recvmsg",               
789         "send",                   /* 285 */
790         "sendmsg",               
791         "sendto",                
792         "setsockopt",            
793         "shutdown",              
794         "socket",                 /* 290 */
795         "socketpair",            
796         "proc_open",             
797         "proc_close",            
798         "proc_send",             
799         "proc_recv",              /* 295 */
800         "proc_sendrecv",         
801         "proc_syscall",          
802         "ipccreate",             
803         "ipcname",               
804         "ipcnamerase",            /* 300 */
805         "ipclookup",             
806         "ipcselect",             
807         "ipcconnect",            
808         "ipcrecvcn",             
809         "ipcsend",                /* 305 */
810         "ipcrecv",               
811         "ipcgetnodename",        
812         "ipcsetnodename",        
813         "ipccontrol",            
814         "ipcshutdown",            /* 310 */
815         "ipcdest",               
816         "semctl",                
817         "msgctl",                
818         "shmctl",                
819         "mpctl",                  /* 315 */
820         "exportfs",              
821         "getpmsg",               
822         "putpmsg",               
823         "strioctl",              
824         "msync",                  /* 320 */
825         "msleep",                
826         "mwakeup",               
827         "msem_init",             
828         "msem_remove",           
829         "adjtime",                /* 325 */
830         "kload",                 
831         "fattach",               
832         "fdetach",               
833         "serialize",             
834         "statvfs",                /* 330 */
835         "fstatvfs",              
836         "lchown",                
837         "getsid",                
838         "sysfs",                 
839         NULL,                     /* 335 */
840         NULL,                    
841         "sched_setparam",        
842         "sched_getparam",        
843         "sched_setscheduler",    
844         "sched_getscheduler",     /* 340 */
845         "sched_yield",           
846         "sched_get_priority_max",
847         "sched_get_priority_min",
848         "sched_rr_get_interval", 
849         "clock_settime",          /* 345 */
850         "clock_gettime",         
851         "clock_getres",          
852         "timer_create",          
853         "timer_delete",          
854         "timer_settime",          /* 350 */
855         "timer_gettime",         
856         "timer_getoverrun",      
857         "nanosleep",             
858         "toolbox",               
859         NULL,                     /* 355 */
860         "getdents",              
861         "getcontext",            
862         "sysinfo",               
863         "fcntl64",               
864         "ftruncate64",            /* 360 */
865         "fstat64",               
866         "getdirentries64",       
867         "getrlimit64",           
868         "lockf64",               
869         "lseek64",                /* 365 */
870         "lstat64",               
871         "mmap64",                
872         "setrlimit64",           
873         "stat64",                
874         "truncate64",             /* 370 */
875         "ulimit64",              
876         NULL,                    
877         NULL,                    
878         NULL,                    
879         NULL,                     /* 375 */
880         NULL,                    
881         NULL,                    
882         NULL,                    
883         NULL,                    
884         "setcontext",             /* 380 */
885         "sigaltstack",           
886         "waitid",                
887         "setpgrp",               
888         "recvmsg2",              
889         "sendmsg2",               /* 385 */
890         "socket2",               
891         "socketpair2",           
892         "setregid",              
893         "lwp_create",            
894         "lwp_terminate",          /* 390 */
895         "lwp_wait",              
896         "lwp_suspend",           
897         "lwp_resume",            
898         "lwp_self",              
899         "lwp_abort_syscall",      /* 395 */
900         "lwp_info",              
901         "lwp_kill",              
902         "ksleep",                
903         "kwakeup",               
904         "ksleep_abort",           /* 400 */
905         "lwp_proc_info",         
906         "lwp_exit",              
907         "lwp_continue",          
908         "getacl",                
909         "fgetacl",                /* 405 */
910         "setacl",                
911         "fsetacl",               
912         "getaccess",             
913         "lwp_mutex_init",        
914         "lwp_mutex_lock_sys",     /* 410 */
915         "lwp_mutex_unlock",      
916         "lwp_cond_init",         
917         "lwp_cond_signal",       
918         "lwp_cond_broadcast",    
919         "lwp_cond_wait_sys",      /* 415 */
920         "lwp_getscheduler",      
921         "lwp_setscheduler",      
922         "lwp_getprivate",        
923         "lwp_setprivate",        
924         "lwp_detach",             /* 420 */
925         "mlock",                 
926         "munlock",               
927         "mlockall",              
928         "munlockall",            
929         "shm_open",               /* 425 */
930         "shm_unlink",            
931         "sigqueue",              
932         "sigwaitinfo",           
933         "sigtimedwait",          
934         "sigwait",                /* 430 */
935         "aio_read",              
936         "aio_write",             
937         "lio_listio",            
938         "aio_error",             
939         "aio_return",             /* 435 */
940         "aio_cancel",            
941         "aio_suspend",           
942         "aio_fsync",             
943         "mq_open",               
944         "mq_unlink",              /* 440 */
945         "mq_send",               
946         "mq_receive",            
947         "mq_notify",             
948         "mq_setattr",            
949         "mq_getattr",             /* 445 */
950         "ksem_open",             
951         "ksem_unlink",           
952         "ksem_close",            
953         "ksem_destroy",          
954         "lw_sem_incr",            /* 450 */
955         "lw_sem_decr",           
956         "lw_sem_read",           
957         "mq_close",              
958 };
959 static const int syscall_names_max = 453;
960
961 int
962 hpux_unimplemented(unsigned long arg1,unsigned long arg2,unsigned long arg3,
963                    unsigned long arg4,unsigned long arg5,unsigned long arg6,
964                    unsigned long arg7,unsigned long sc_num)
965 {
966         /* NOTE: sc_num trashes arg8 for the few syscalls that actually
967          * have a valid 8th argument.
968          */
969         const char *name = NULL;
970         if ( sc_num <= syscall_names_max && sc_num >= 0 ) {
971                 name = syscall_names[sc_num];
972         }
973
974         if ( name ) {
975                 printk(KERN_DEBUG "Unimplemented HP-UX syscall emulation. Syscall #%lu (%s)\n",
976                 sc_num, name);
977         } else {
978                 printk(KERN_DEBUG "Unimplemented unknown HP-UX syscall emulation. Syscall #%lu\n",
979                 sc_num);
980         }
981         
982         printk(KERN_DEBUG "  Args: %lx %lx %lx %lx %lx %lx %lx\n",
983                 arg1, arg2, arg3, arg4, arg5, arg6, arg7);
984
985         return -ENOSYS;
986 }