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