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