2 * linux/arch/parisc/kernel/sys_hpux.c
4 * implements HPUX syscalls.
7 #include <linux/sched.h>
8 #include <linux/smp_lock.h>
9 #include <linux/utsname.h>
10 #include <asm/errno.h>
11 #include <asm/uaccess.h>
13 unsigned long sys_brk(unsigned long addr);
15 unsigned long hpux_brk(unsigned long addr)
17 /* Sigh. Looks like HP/UX libc relies on kernel bugs. */
18 return sys_brk(addr + PAGE_SIZE);
26 /* Random other syscalls */
28 int hpux_nice(int priority_change)
38 int hpux_wait(int *stat_loc)
40 extern int sys_waitpid(int, int *, int);
41 return sys_waitpid(-1, stat_loc, 0);
44 #define _SC_CPU_VERSION 10001
45 #define _SC_OPEN_MAX 4
46 #define CPU_PA_RISC1_1 0x210
48 int hpux_sysconf(int which)
52 return CPU_PA_RISC1_1;
60 /*****************************************************************************/
66 char sysname[HPUX_UTSLEN];
67 char nodename[HPUX_UTSLEN];
68 char release[HPUX_UTSLEN];
69 char version[HPUX_UTSLEN];
70 char machine[HPUX_UTSLEN];
71 char idnumber[HPUX_SNLEN];
75 int32_t f_tfree; /* total free (daddr_t) */
76 u_int32_t f_tinode; /* total inodes free (ino_t) */
77 char f_fname[6]; /* filsys name */
78 char f_fpack[6]; /* filsys pack name */
79 u_int32_t f_blksize; /* filsys block size (int) */
83 * HPUX's utssys() call. It's a collection of miscellaneous functions,
84 * alas, so there's no nice way of splitting them up.
87 /* This function is called from hpux_utssys(); HP-UX implements
88 * ustat() as an option to utssys().
90 * Now, struct ustat on HP-UX is exactly the same as on Linux, except
91 * that it contains one addition field on the end, int32_t f_blksize.
92 * So, we could have written this function to just call the Linux
93 * sys_ustat(), (defined in linux/fs/super.c), and then just
94 * added this additional field to the user's structure. But I figure
95 * if we're gonna be digging through filesystem structures to get
96 * this, we might as well just do the whole enchilada all in one go.
98 * So, most of this function is almost identical to sys_ustat().
99 * I have placed comments at the few lines changed or added, to
100 * aid in porting forward if and when sys_ustat() is changed from
101 * its form in kernel 2.2.5.
103 static int hpux_ustat(dev_t dev, struct hpux_ustat *ubuf)
105 struct super_block *s;
106 struct hpux_ustat tmp; /* Changed to hpux_ustat */
111 s = get_super(to_kdev_t(dev));
114 err = vfs_statfs(s, &sbuf);
118 memset(&tmp,0,sizeof(struct hpux_ustat)); /* Changed to hpux_ustat */
120 tmp.f_tfree = (int32_t)sbuf.f_bfree;
121 tmp.f_tinode = (u_int32_t)sbuf.f_ffree;
122 tmp.f_blksize = (u_int32_t)sbuf.f_bsize; /* Added this line */
124 /* Changed to hpux_ustat: */
125 err = copy_to_user(ubuf,&tmp,sizeof(struct hpux_ustat)) ? -EFAULT : 0;
132 /* This function is called from hpux_utssys(); HP-UX implements
133 * uname() as an option to utssys().
135 * The form of this function is pretty much copied from sys_olduname(),
136 * defined in linux/arch/i386/kernel/sys_i386.c.
138 /* TODO: Are these put_user calls OK? Should they pass an int?
139 * (I copied it from sys_i386.c like this.)
141 static int hpux_uname(struct hpux_utsname *name)
147 if (!access_ok(VERIFY_WRITE,name,sizeof(struct hpux_utsname)))
152 error = __copy_to_user(&name->sysname,&system_utsname.sysname,HPUX_UTSLEN-1);
153 error |= __put_user(0,name->sysname+HPUX_UTSLEN-1);
154 error |= __copy_to_user(&name->nodename,&system_utsname.nodename,HPUX_UTSLEN-1);
155 error |= __put_user(0,name->nodename+HPUX_UTSLEN-1);
156 error |= __copy_to_user(&name->release,&system_utsname.release,HPUX_UTSLEN-1);
157 error |= __put_user(0,name->release+HPUX_UTSLEN-1);
158 error |= __copy_to_user(&name->version,&system_utsname.version,HPUX_UTSLEN-1);
159 error |= __put_user(0,name->version+HPUX_UTSLEN-1);
160 error |= __copy_to_user(&name->machine,&system_utsname.machine,HPUX_UTSLEN-1);
161 error |= __put_user(0,name->machine+HPUX_UTSLEN-1);
165 /* HP-UX utsname has no domainname field. */
167 /* TODO: Implement idnumber!!! */
169 error |= __put_user(0,name->idnumber);
170 error |= __put_user(0,name->idnumber+HPUX_SNLEN-1);
173 error = error ? -EFAULT : 0;
178 int sys_sethostname(char *, int);
179 int sys_gethostname(char *, int);
181 /* Note: HP-UX just uses the old suser() function to check perms
182 * in this system call. We'll use capable(CAP_SYS_ADMIN).
184 int hpux_utssys(char *ubuf, int n, int type)
191 return( hpux_uname( (struct hpux_utsname *)ubuf ) );
194 /* Obsolete (used to be umask().) */
199 return( hpux_ustat((dev_t)n, (struct hpux_ustat *)ubuf) );
204 * On linux (unlike HP-UX), utsname.nodename
205 * is the same as the hostname.
207 * sys_sethostname() is defined in linux/kernel/sys.c.
209 if (!capable(CAP_SYS_ADMIN))
211 /* Unlike Linux, HP-UX returns an error if n==0: */
214 /* Unlike Linux, HP-UX truncates it if n is too big: */
215 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
216 return( sys_sethostname(ubuf, len) );
221 * sys_sethostname() is defined in linux/kernel/sys.c.
223 if (!capable(CAP_SYS_ADMIN))
225 /* Unlike Linux, HP-UX returns an error if n==0: */
228 /* Unlike Linux, HP-UX truncates it if n is too big: */
229 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
230 return( sys_sethostname(ubuf, len) );
235 * sys_gethostname() is defined in linux/kernel/sys.c.
237 /* Unlike Linux, HP-UX returns an error if n==0: */
240 return( sys_gethostname(ubuf, n) );
243 /* Supposedly called from setuname() in libc.
244 * TODO: When and why is this called?
245 * Is it ever even called?
247 * This code should look a lot like sys_sethostname(),
248 * defined in linux/kernel/sys.c. If that gets updated,
249 * update this code similarly.
251 if (!capable(CAP_SYS_ADMIN))
253 /* Unlike Linux, HP-UX returns an error if n==0: */
256 /* Unlike Linux, HP-UX truncates it if n is too big: */
257 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
259 /* TODO: print a warning about using this? */
260 down_write(&uts_sem);
262 if (!copy_from_user(system_utsname.sysname, ubuf, len)) {
263 system_utsname.sysname[len] = 0;
270 /* Sets utsname.release, if you're allowed.
271 * Undocumented. Used by swinstall to change the
272 * OS version, during OS updates. Yuck!!!
274 * This code should look a lot like sys_sethostname()
275 * in linux/kernel/sys.c. If that gets updated, update
276 * this code similarly.
278 if (!capable(CAP_SYS_ADMIN))
280 /* Unlike Linux, HP-UX returns an error if n==0: */
283 /* Unlike Linux, HP-UX truncates it if n is too big: */
284 len = (n <= __NEW_UTS_LEN) ? n : __NEW_UTS_LEN ;
286 /* TODO: print a warning about this? */
287 down_write(&uts_sem);
289 if (!copy_from_user(system_utsname.release, ubuf, len)) {
290 system_utsname.release[len] = 0;
297 /* This system call returns -EFAULT if given an unknown type.
298 * Why not -EINVAL? I don't know, it's just not what they did.
304 int hpux_getdomainname(char *name, int len)
311 nlen = strlen(system_utsname.domainname) + 1;
315 if(len > __NEW_UTS_LEN)
317 if(copy_to_user(name, system_utsname.domainname, len))
326 int hpux_pipe(int *kstack_fildes)
331 error = do_pipe(kstack_fildes);