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