aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc/hpux/sys_hpux.c
blob: 18072e03a019e1411b88a5e0b3fa1ee48e2b6458 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
/*
 *    Implements HPUX syscalls.
 *
 *    Copyright (C) 1999 Matthew Wilcox <willy with parisc-linux.org>
 *    Copyright (C) 2000 Philipp Rumpf
 *    Copyright (C) 2000 John Marvin <jsm with parisc-linux.org>
 *    Copyright (C) 2000 Michael Ang <mang with subcarrier.org>
 *    Copyright (C) 2001 Nathan Neulinger <nneul at umr.edu>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <linux/capability.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/namei.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/smp_lock.h>
#include <linux/syscalls.h>
#include <linux/utsname.h>
#include <linux/vfs.h>
#include <linux/vmalloc.h>

#include <asm/errno.h>
#include <asm/pgalloc.h>
#include <asm/uaccess.h>

unsigned long hpux_brk(unsigned long addr)
{
	/* Sigh.  Looks like HP/UX libc relies on kernel bugs. */
	return sys_brk(addr + PAGE_SIZE);
}

int hpux_sbrk(void)
{
	return -ENOSYS;
}

/* Random other syscalls */

int hpux_nice(int priority_change)
{
	return -ENOSYS;
}

int hpux_ptrace(void)
{
	return -ENOSYS;
}

int hpux_wait(int __user *stat_loc)
{
	return sys_waitpid(-1, stat_loc, 0);
}

int hpux_setpgrp(void)
{
	return sys_setpgid(0,0);
}

int hpux_setpgrp3(void)
{
	return hpux_setpgrp();
}

#define _SC_CPU_VERSION	10001
#define _SC_OPEN_MAX	4
#define CPU_PA_RISC1_1	0x210

int hpux_sysconf(int which)
{
	switch (which) {
	case _SC_CPU_VERSION:
		return CPU_PA_RISC1_1;
	case _SC_OPEN_MAX:
		return INT_MAX;
	default:
		return -EINVAL;
	}
}

/*****************************************************************************/

#define HPUX_UTSLEN 9
#define HPUX_SNLEN 15

struct hpux_utsname {
	char sysname[HPUX_UTSLEN];
	char nodename[HPUX_UTSLEN];
	char release[HPUX_UTSLEN];
	char version[HPUX_UTSLEN];
	char machine[HPUX_UTSLEN];
	char idnumber[HPUX_SNLEN];
} ;

struct hpux_ustat {
	int32_t		f_tfree;	/* total free (daddr_t)  */
	u_int32_t	f_tinode;	/* total inodes free (ino_t)  */
	char		f_fname[6];	/* filsys name */
	char		f_fpack[6];	/* filsys pack name */
	u_int32_t	f_blksize;	/* filsys block size (int) */
};

/*
 * HPUX's utssys() call.  It's a collection of miscellaneous functions,
 * alas, so there's no nice way of splitting them up.
 */

/*  This function is called from hpux_utssys(); HP-UX implements
 *  ustat() as an option to utssys().
 *
 *  Now, struct ustat on HP-UX is exactly the same as on Linux, except
 *  that it contains one addition field on the end, int32_t f_blksize.
 *  So, we could have written this function to just call the Linux
 *  sys_ustat(), (defined in linux/fs/super.c), and then just
 *  added this additional field to the user's structure.  But I figure
 *  if we're gonna be digging through filesystem structures to get
 *  this, we might as well just do the whole enchilada all in one go.
 *
 *  So, most of this function is almost identical to sys_ustat().
 *  I have placed comments at the few lines changed or added, to
 *  aid in porting forward if and when sys_ustat() is changed from
 *  its form in kernel 2.2.5.
 */
static int hpux_ustat(dev_t dev, struct hpux_ustat __user *ubuf)
{
	struct super_block *s;
	struct hpux_ustat tmp;  /* Changed to hpux_ustat */
	struct kstatfs sbuf;
	int err = -EINVAL;

	s = user_get_super(dev);
	if (s == NULL)
		goto out;
	err = vfs_statfs(s->s_root, &sbuf);
	drop_super(s);
	if (err)
		goto out;

	memset(&tmp,0,sizeof(tmp));

	tmp.f_tfree = (int32_t)sbuf.f_bfree;
	tmp.f_tinode = (u_int32_t)sbuf.f_ffree;
	tmp.f_blksize = (u_int32_t)sbuf.f_bsize;  /*  Added this line  */

	err = copy_to_user(ubuf, &tmp, sizeof(tmp)) ? -EFAULT : 0;
out:
	return err;
}

/*
 * Wrapper for hpux statfs call. At the moment, just calls the linux native one
 * and ignores the extra fields at the end of the hpux statfs struct.
 *
 */

typedef int32_t hpux_fsid_t[2];              /* file system ID type */
typedef uint16_t hpux_site_t;

struct hpux_statfs {
     int32_t f_type;                    /* type of info, zero for now */
     int32_t f_bsize;                   /* fundamental file system block size */
     int32_t f_blocks;                  /* total blocks in file system */
     int32_t f_bfree;                   /* free block in fs */
     int32_t f_bavail;                  /* free blocks avail to non-superuser */
     int32_t f_files;                   /* total file nodes in file system */
     int32_t f_ffree;                   /* free file nodes in fs */
     hpux_fsid_t  f_fsid;                    /* file system ID */
     int32_t f_magic;                   /* file system magic number */
     int32_t f_featurebits;             /* file system features */
     int32_t f_spare[4];                /* spare for later */
     hpux_site_t  f_cnode;                   /* cluster node where mounted */
     int16_t f_pad;
};

static int vfs_statfs_hpux(struct dentry *dentry, struct hpux_statfs *buf)
{
	struct kstatfs st;
	int retval;
	
	retval = vfs_statfs(dentry, &st);
	if (retval)
		return retval;

	memset(buf, 0, sizeof(*buf));
	buf->f_type = st.f_type;
	buf->f_bsize = st.f_bsize;
	buf->f_blocks = st.f_blocks;
	buf->f_bfree = st.f_bfree;
	buf->f_bavail = st.f_bavail;
	buf->f_files = st.f_files;
	buf->f_ffree = st.f_ffree;
	buf->f_fsid[0] = st.f_fsid.val[0];
	buf->f_fsid[1] = st.f_fsid.val[1];

	return 0;
}

/* hpux statfs */
asmlinkage long hpux_statfs(const char __user *pathname,
						struct hpux_statfs __user *buf)
{
	struct path path;
	int error;

	error = user_path(pathname, &path);
	if (!error) {
		struct hpux_statfs tmp;
		error = vfs_statfs_hpux(path.dentry, &tmp);
		if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
			error = -EFAULT;
		path_put(&path);
	}
	return error;
}

asmlinkage long hpux_fstatfs(unsigned int fd, struct hpux_statfs __user * buf)
{
	struct file *file;
	struct hpux_statfs tmp;
	int error;

	error = -EBADF;
	file = fget(fd);
	if (!file)
		goto out;
	error = vfs_statfs_hpux(file->f_path.dentry, &tmp);
	if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
		error = -EFAULT;
	fput(file);
 out:
	return error;
}


/*  This function is called from hpux_utssys(); HP-UX implements
 *  uname() as an option to utssys().
 *
 *  The form of this function is pretty much copied from sys_olduname(),
 *  defined in linux/arch/i386/kernel/sys_i386.c.
 */
/*  TODO: Are these put_user calls OK?  Should they pass an int?
 *        (I copied it from sys_i386.c like this.)
 */
static int hpux_uname(struct hpux_utsname __user *name)
{
	int error;

	if (!name)
		return -EFAULT;
	if (!access_ok(VERIFY_WRITE,name,sizeof(struct hpux_utsname)))
		return -EFAULT;

	down_read(&uts_sem);

	error = __copy_to_user(&name->sysname, &utsname()->sysname,
			       HPUX_UTSLEN - 1);
	error |= __put_user(0, name->sysname + HPUX_UTSLEN - 1);
	error |= __copy_to_user(&name->nodename, &utsname()->nodename,
				HPUX_UTSLEN - 1);
	error |= __put_user(0, name->nodename + HPUX_UTSLEN - 1);
	error |= __copy_to_user(&name->release, &utsname()->release,
				HPUX_UTSLEN - 1);
	error |= __put_user(0, name->release + HPUX_UTSLEN - 1);
	error |= __copy_to_user(&name->version, &utsname()->version,
				HPUX_UTSLEN - 1);
	error |= __put_user(0, name->version + HPUX_UTSLEN - 1);
	error |= __copy_to_user(&name->machine, &utsname()->machine,
				HPUX_UTSLEN - 1);
	error |= __put_user(0, name->machine + HPUX_UTSLEN - 1);

	up_read(&uts_sem);

	/*  HP-UX  utsname has no domainname field.  */

	/*  TODO:  Implement idnumber!!!  */
#if 0
	error |= __put_user(0,name->idnumber);
	error |= __put_user(0,name->idnumber+HPUX_SNLEN-1);
#endif

	error = error ? -EFAULT : 0;

	return error;
}

/*  Note: HP-UX just uses the old suser() function to check perms
 *  in this system call.  We'll use capable(CAP_SYS_ADMIN).
 */
int hpux_utssys(char __user *ubuf, int n, int type)
{
	int len;
	int error;
	switch( type ) {
	case 0:
		/*  uname():  */
		return hpux_uname((struct hpux_utsname __user *)ubuf);
		break ;
	case 1:
		/*  Obsolete (used to be umask().)  */
		return -EFAULT ;
		break ;
	case 2:
		/*  ustat():  */
		return hpux_ustat(new_decode_dev(n),
				  (struct hpux_ustat __user *)ubuf);
		break;
	case 3:
		/*  setuname():
		 *
		 *  On linux (unlike HP-UX), utsname.nodename
		 *  is the same as the hostname.
		 *
		 *  sys_sethostname() is defined in linux/kernel/sys.c.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		return sys_sethostname(ubuf, len);
		break ;
	case 4:
		/*  sethostname():
		 *
		 *  sys_sethostname() is defined in linux/kernel/sys.c.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		return sys_sethostname(ubuf, len);
		break ;
	case 5:
		/*  gethostname():
		 *
		 *  sys_gethostname() is defined in linux/kernel/sys.c.
		 */
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		return sys_gethostname(ubuf, n);
		break ;
	case 6:
		/*  Supposedly called from setuname() in libc.
		 *  TODO: When and why is this called?
		 *        Is it ever even called?
		 *
		 *  This code should look a lot like sys_sethostname(),
		 *  defined in linux/kernel/sys.c.  If that gets updated,
		 *  update this code similarly.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		/**/
		/*  TODO:  print a warning about using this?  */
		down_write(&uts_sem);
		error = -EFAULT;
		if (!copy_from_user(utsname()->sysname, ubuf, len)) {
			utsname()->sysname[len] = 0;
			error = 0;
		}
		up_write(&uts_sem);
		return error;
		break ;
	case 7:
		/*  Sets utsname.release, if you're allowed.
		 *  Undocumented.  Used by swinstall to change the
		 *  OS version, during OS updates.  Yuck!!!
		 *
		 *  This code should look a lot like sys_sethostname()
		 *  in linux/kernel/sys.c.  If that gets updated, update
		 *  this code similarly.
		 */
		if (!capable(CAP_SYS_ADMIN))
			return -EPERM;
		/*  Unlike Linux, HP-UX returns an error if n==0:  */
		if ( n <= 0 )
			return -EINVAL ;
		/*  Unlike Linux, HP-UX truncates it if n is too big:  */
		len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
		/**/
		/*  TODO:  print a warning about this?  */
		down_write(&uts_sem);
		error = -EFAULT;
		if (!copy_from_user(utsname()->release, ubuf, len)) {
			utsname()->release[len] = 0;
			error = 0;
		}
		up_write(&uts_sem);
		return error;
		break ;
	default:
		/*  This system call returns -EFAULT if given an unknown type.
	 	 *  Why not -EINVAL?  I don't know, it's just not what they did.
	 	 */
		return -EFAULT ;
	}
}

int hpux_getdomainname(char __user *name, int len)
{
 	int nlen;
 	int err = -EFAULT;
 	
 	down_read(&uts_sem);
 	
	nlen = strlen(utsname()->domainname) + 1;

	if (nlen < len)
		len = nlen;
	if(len > __NEW_UTS_LEN)
		goto done;
	if(copy_to_user(name, utsname()->domainname, len))
		goto done;
	err = 0;
done:
	up_read(&uts_sem);
	return err;
	
}

int hpux_pipe(int *kstack_fildes)
{
	int error;

	lock_kernel();
	error = do_pipe_flags(kstack_fildes, 0);
	unlock_kernel();
	return error;
}

/* lies - says it works, but it really didn't lock anything */
int hpux_lockf(int fildes, int function, off_t size)
{
	return 0;
}

int hpux_sysfs(int opcode, unsigned long arg1, unsigned long arg2)
{
	char *fsname = NULL;
	int len = 0;
	int fstype;

/*Unimplemented HP-UX syscall emulation. Syscall #334 (sysfs)
  Args: 1 80057bf4 0 400179f0 0 0 0 */
	printk(KERN_DEBUG "in hpux_sysfs\n");
	printk(KERN_DEBUG "hpux_sysfs called with opcode = %d\n", opcode);
	printk(KERN_DEBUG "hpux_sysfs called with arg1='%lx'\n", arg1);

	if ( opcode == 1 ) { /* GETFSIND */	
		char __user *user_fsname = (char __user *)arg1;
		len = strlen_user(user_fsname);
		printk(KERN_DEBUG "len of arg1 = %d\n", len);
		if (len == 0)
			return 0;
		fsname = kmalloc(len, GFP_KERNEL);
		if (!fsname) {
			printk(KERN_DEBUG "failed to kmalloc fsname\n");
			return 0;
		}

		if (copy_from_user(fsname, user_fsname, len)) {
			printk(KERN_DEBUG "failed to copy_from_user fsname\n");
			kfree(fsname);
			return 0;
		}

		/* String could be altered by userspace after strlen_user() */
		fsname[len] = '\0';

		printk(KERN_DEBUG "that is '%s' as (char *)\n", fsname);
		if ( !strcmp(fsname, "hfs") ) {
			fstype = 0;
		} else {
			fstype = 0;
		}

		kfree(fsname);

		printk(KERN_DEBUG "returning fstype=%d\n", fstype);
		return fstype; /* something other than default */
	}


	return 0;
}


/* Table of syscall names and handle for unimplemented routines */
static const char * const syscall_names[] = {
	"nosys",                  /* 0 */
	"exit",                  
	"fork",                  
	"read",                  
	"write",                 
	"open",                   /* 5 */
	"close",                 
	"wait",                  
	"creat",                 
	"link",                  
	"unlink",                 /* 10 */
	"execv",                 
	"chdir",                 
	"time",                  
	"mknod",                 
	"chmod",                  /* 15 */
	"chown",                 
	"brk",                   
	"lchmod",                
	"lseek",                 
	"getpid",                 /* 20 */
	"mount",                 
	"umount",                
	"setuid",                
	"getuid",                
	"stime",                  /* 25 */
	"ptrace",                
	"alarm",                 
	NULL,                    
	"pause",                 
	"utime",                  /* 30 */
	"stty",                  
	"gtty",                  
	"access",                
	"nice",                  
	"ftime",                  /* 35 */
	"sync",                  
	"kill",                  
	"stat",                  
	"setpgrp3",              
	"lstat",                  /* 40 */
	"dup",                   
	"pipe",                  
	"times",                 
	"profil",                
	"ki_call",                /* 45 */
	"setgid",                
	"getgid",                
	NULL,                    
	NULL,                    
	NULL,                     /* 50 */
	"acct",                  
	"set_userthreadid",      
	NULL,                    
	"ioctl",                 
	"reboot",                 /* 55 */
	"symlink",               
	"utssys",                
	"readlink",              
	"execve",                
	"umask",                  /* 60 */
	"chroot",                
	"fcntl",                 
	"ulimit",                
	NULL,                    
	NULL,                     /* 65 */
	"vfork",                 
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 70 */
	"mmap",                  
	NULL,                    
	"munmap",                
	"mprotect",              
	"madvise",                /* 75 */
	"vhangup",               
	"swapoff",               
	NULL,                    
	"getgroups",             
	"setgroups",              /* 80 */
	"getpgrp2",              
	"setpgid/setpgrp2",      
	"setitimer",             
	"wait3",                 
	"swapon",                 /* 85 */
	"getitimer",             
	NULL,                    
	NULL,                    
	NULL,                    
	"dup2",                   /* 90 */
	NULL,                    
	"fstat",                 
	"select",                
	NULL,                    
	"fsync",                  /* 95 */
	"setpriority",           
	NULL,                    
	NULL,                    
	NULL,                    
	"getpriority",            /* 100 */
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 105 */
	NULL,                    
	NULL,                    
	"sigvector",             
	"sigblock",              
	"sigsetmask",             /* 110 */
	"sigpause",              
	"sigstack",              
	NULL,                    
	NULL,                    
	NULL,                     /* 115 */
	"gettimeofday",          
	"getrusage",             
	NULL,                    
	NULL,                    
	"readv",                  /* 120 */
	"writev",                
	"settimeofday",          
	"fchown",                
	"fchmod",                
	NULL,                     /* 125 */
	"setresuid",             
	"setresgid",             
	"rename",                
	"truncate",              
	"ftruncate",              /* 130 */
	NULL,                    
	"sysconf",               
	NULL,                    
	NULL,                    
	NULL,                     /* 135 */
	"mkdir",                 
	"rmdir",                 
	NULL,                    
	"sigcleanup",            
	"setcore",                /* 140 */
	NULL,                    
	"gethostid",             
	"sethostid",             
	"getrlimit",             
	"setrlimit",              /* 145 */
	NULL,                    
	NULL,                    
	"quotactl",              
	"get_sysinfo",           
	NULL,                     /* 150 */
	"privgrp",               
	"rtprio",                
	"plock",                 
	NULL,                    
	"lockf",                  /* 155 */
	"semget",                
	NULL,                    
	"semop",                 
	"msgget",                
	NULL,                     /* 160 */
	"msgsnd",                
	"msgrcv",                
	"shmget",                
	NULL,                    
	"shmat",                  /* 165 */
	"shmdt",                 
	NULL,                    
	"csp/nsp_init",          
	"cluster",               
	"mkrnod",                 /* 170 */
	"test",                  
	"unsp_open",             
	NULL,                    
	"getcontext",            
	"osetcontext",            /* 175 */
	"bigio",                 
	"pipenode",              
	"lsync",                 
	"getmachineid",          
	"cnodeid/mysite",         /* 180 */
	"cnodes/sitels",         
	"swapclients",           
	"rmtprocess",            
	"dskless_stats",         
	"sigprocmask",            /* 185 */
	"sigpending",            
	"sigsuspend",            
	"sigaction",             
	NULL,                    
	"nfssvc",                 /* 190 */
	"getfh",                 
	"getdomainname",         
	"setdomainname",         
	"async_daemon",          
	"getdirentries",          /* 195 */
	NULL,                
	NULL,               
	"vfsmount",              
	NULL,                    
	"waitpid",                /* 200 */
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 205 */
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 210 */
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 215 */
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 220 */
	NULL,                    
	NULL,                    
	NULL,                    
	"sigsetreturn",          
	"sigsetstatemask",        /* 225 */
	"bfactl",                
	"cs",                    
	"cds",                   
	NULL,                    
	"pathconf",               /* 230 */
	"fpathconf",             
	NULL,                    
	NULL,                    
	"nfs_fcntl",             
	"ogetacl",                /* 235 */
	"ofgetacl",              
	"osetacl",               
	"ofsetacl",              
	"pstat",                 
	"getaudid",               /* 240 */
	"setaudid",              
	"getaudproc",            
	"setaudproc",            
	"getevent",              
	"setevent",               /* 245 */
	"audwrite",              
	"audswitch",             
	"audctl",                
	"ogetaccess",            
	"fsctl",                  /* 250 */
	"ulconnect",             
	"ulcontrol",             
	"ulcreate",              
	"uldest",                
	"ulrecv",                 /* 255 */
	"ulrecvcn",              
	"ulsend",                
	"ulshutdown",            
	"swapfs",                
	"fss",                    /* 260 */
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 265 */
	NULL,                    
	"tsync",                 
	"getnumfds",             
	"poll",                  
	"getmsg",                 /* 270 */
	"putmsg",                
	"fchdir",                
	"getmount_cnt",          
	"getmount_entry",        
	"accept",                 /* 275 */
	"bind",                  
	"connect",               
	"getpeername",           
	"getsockname",           
	"getsockopt",             /* 280 */
	"listen",                
	"recv",                  
	"recvfrom",              
	"recvmsg",               
	"send",                   /* 285 */
	"sendmsg",               
	"sendto",                
	"setsockopt",            
	"shutdown",              
	"socket",                 /* 290 */
	"socketpair",            
	"proc_open",             
	"proc_close",            
	"proc_send",             
	"proc_recv",              /* 295 */
	"proc_sendrecv",         
	"proc_syscall",          
	"ipccreate",             
	"ipcname",               
	"ipcnamerase",            /* 300 */
	"ipclookup",             
	"ipcselect",             
	"ipcconnect",            
	"ipcrecvcn",             
	"ipcsend",                /* 305 */
	"ipcrecv",               
	"ipcgetnodename",        
	"ipcsetnodename",        
	"ipccontrol",            
	"ipcshutdown",            /* 310 */
	"ipcdest",               
	"semctl",                
	"msgctl",                
	"shmctl",                
	"mpctl",                  /* 315 */
	"exportfs",              
	"getpmsg",               
	"putpmsg",               
	"strioctl",              
	"msync",                  /* 320 */
	"msleep",                
	"mwakeup",               
	"msem_init",             
	"msem_remove",           
	"adjtime",                /* 325 */
	"kload",                 
	"fattach",               
	"fdetach",               
	"serialize",             
	"statvfs",                /* 330 */
	"fstatvfs",              
	"lchown",                
	"getsid",                
	"sysfs",                 
	NULL,                     /* 335 */
	NULL,                    
	"sched_setparam",        
	"sched_getparam",        
	"sched_setscheduler",    
	"sched_getscheduler",     /* 340 */
	"sched_yield",           
	"sched_get_priority_max",
	"sched_get_priority_min",
	"sched_rr_get_interval", 
	"clock_settime",          /* 345 */
	"clock_gettime",         
	"clock_getres",          
	"timer_create",          
	"timer_delete",          
	"timer_settime",          /* 350 */
	"timer_gettime",         
	"timer_getoverrun",      
	"nanosleep",             
	"toolbox",               
	NULL,                     /* 355 */
	"getdents",              
	"getcontext",            
	"sysinfo",               
	"fcntl64",               
	"ftruncate64",            /* 360 */
	"fstat64",               
	"getdirentries64",       
	"getrlimit64",           
	"lockf64",               
	"lseek64",                /* 365 */
	"lstat64",               
	"mmap64",                
	"setrlimit64",           
	"stat64",                
	"truncate64",             /* 370 */
	"ulimit64",              
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                     /* 375 */
	NULL,                    
	NULL,                    
	NULL,                    
	NULL,                    
	"setcontext",             /* 380 */
	"sigaltstack",           
	"waitid",                
	"setpgrp",               
	"recvmsg2",              
	"sendmsg2",               /* 385 */
	"socket2",               
	"socketpair2",           
	"setregid",              
	"lwp_create",            
	"lwp_terminate",          /* 390 */
	"lwp_wait",              
	"lwp_suspend",           
	"lwp_resume",            
	"lwp_self",              
	"lwp_abort_syscall",      /* 395 */
	"lwp_info",              
	"lwp_kill",              
	"ksleep",                
	"kwakeup",               
	"ksleep_abort",           /* 400 */
	"lwp_proc_info",         
	"lwp_exit",              
	"lwp_continue",          
	"getacl",                
	"fgetacl",                /* 405 */
	"setacl",                
	"fsetacl",               
	"getaccess",             
	"lwp_mutex_init",        
	"lwp_mutex_lock_sys",     /* 410 */
	"lwp_mutex_unlock",      
	"lwp_cond_init",         
	"lwp_cond_signal",       
	"lwp_cond_broadcast",    
	"lwp_cond_wait_sys",      /* 415 */
	"lwp_getscheduler",      
	"lwp_setscheduler",      
	"lwp_getprivate",        
	"lwp_setprivate",        
	"lwp_detach",             /* 420 */
	"mlock",                 
	"munlock",               
	"mlockall",              
	"munlockall",            
	"shm_open",               /* 425 */
	"shm_unlink",            
	"sigqueue",              
	"sigwaitinfo",           
	"sigtimedwait",          
	"sigwait",                /* 430 */
	"aio_read",              
	"aio_write",             
	"lio_listio",            
	"aio_error",             
	"aio_return",             /* 435 */
	"aio_cancel",            
	"aio_suspend",           
	"aio_fsync",             
	"mq_open",               
	"mq_unlink",              /* 440 */
	"mq_send",               
	"mq_receive",            
	"mq_notify",             
	"mq_setattr",            
	"mq_getattr",             /* 445 */
	"ksem_open",             
	"ksem_unlink",           
	"ksem_close",            
	"ksem_destroy",          
	"lw_sem_incr",            /* 450 */
	"lw_sem_decr",           
	"lw_sem_read",           
	"mq_close",              
};
static const int syscall_names_max = 453;

int
hpux_unimplemented(unsigned long arg1,unsigned long arg2,unsigned long arg3,
		   unsigned long arg4,unsigned long arg5,unsigned long arg6,
		   unsigned long arg7,unsigned long sc_num)
{
	/* NOTE: sc_num trashes arg8 for the few syscalls that actually
	 * have a valid 8th argument.
	 */
	const char *name = NULL;
	if ( sc_num <= syscall_names_max && sc_num >= 0 ) {
		name = syscall_names[sc_num];
	}

	if ( name ) {
		printk(KERN_DEBUG "Unimplemented HP-UX syscall emulation. Syscall #%lu (%s)\n",
		sc_num, name);
	} else {
		printk(KERN_DEBUG "Unimplemented unknown HP-UX syscall emulation. Syscall #%lu\n",
		sc_num);
	}
	
	printk(KERN_DEBUG "  Args: %lx %lx %lx %lx %lx %lx %lx\n",
		arg1, arg2, arg3, arg4, arg5, arg6, arg7);

	return -ENOSYS;
}