Line | |
---|
1 | /*
|
---|
2 | ** primos.c
|
---|
3 | **
|
---|
4 | ** This file contains emulation routines for some common Unix functions
|
---|
5 | **
|
---|
6 | ** Author: Peter Eriksson <pen@lysator.liu.se>
|
---|
7 | */
|
---|
8 |
|
---|
9 | #ifdef __50SERIES
|
---|
10 |
|
---|
11 | #include <stdio.h>
|
---|
12 | #include <fcntl.h>
|
---|
13 | #include <sys/stat.h>
|
---|
14 |
|
---|
15 |
|
---|
16 | uid_t primos_uid = 42;
|
---|
17 | gid_t primos_gid = 42;
|
---|
18 | mode_t primos_mode = 600;
|
---|
19 |
|
---|
20 | /* Dummy do-nothing routine for chmod() */
|
---|
21 | int chmod(path, mode)
|
---|
22 | char *path;
|
---|
23 | int mode;
|
---|
24 | {
|
---|
25 | return 0;
|
---|
26 | }
|
---|
27 |
|
---|
28 | char *getenv(var)
|
---|
29 | char *var;
|
---|
30 | {
|
---|
31 | char buf[256];
|
---|
32 | extern char *gvget();
|
---|
33 |
|
---|
34 | buf[0] = '.';
|
---|
35 | strcpy(buf+1, var);
|
---|
36 |
|
---|
37 | return gvget(buf);
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 | unlink(path)
|
---|
42 | char *path;
|
---|
43 | {
|
---|
44 | return delete(path);
|
---|
45 | }
|
---|
46 |
|
---|
47 | int lstat(path, buf)
|
---|
48 | char *path;
|
---|
49 | struct stat *buf;
|
---|
50 | {
|
---|
51 | return stat(path, buf);
|
---|
52 | }
|
---|
53 |
|
---|
54 | int stat(path, buf)
|
---|
55 | char *path;
|
---|
56 | struct stat *buf;
|
---|
57 | {
|
---|
58 | buf->st_dev = 1;
|
---|
59 | buf->st_ino = 1;
|
---|
60 | buf->st_nlink = 1;
|
---|
61 | buf->st_uid = primos_uid;
|
---|
62 | buf->st_gid = primos_gid;
|
---|
63 | buf->st_rdev = 1;
|
---|
64 | buf->st_blksize = 2048;
|
---|
65 |
|
---|
66 | buf->st_rwlock = frwlock(path);
|
---|
67 | switch (buf->st_type = ftype(path))
|
---|
68 | {
|
---|
69 | case 0:
|
---|
70 | case 1:
|
---|
71 | /* Regular file (SAM or DAM) */
|
---|
72 | buf->st_size = fsize(path);
|
---|
73 | buf->st_mtime = fdtm(path);
|
---|
74 |
|
---|
75 | buf->st_mode = S_IFREG|primos_mode;
|
---|
76 | break;
|
---|
77 |
|
---|
78 | case 4:
|
---|
79 | buf->st_size = 0;
|
---|
80 | buf->st_mtime = fdtm(path);
|
---|
81 |
|
---|
82 | buf->st_mode = S_IFDIR|primos_mode;
|
---|
83 | break;
|
---|
84 |
|
---|
85 | case -1:
|
---|
86 | return -1;
|
---|
87 |
|
---|
88 | default:
|
---|
89 | buf->st_mode = primos_mode;
|
---|
90 | buf->st_size = fsize(path);
|
---|
91 | buf->st_mtime = fdtm(path);
|
---|
92 | }
|
---|
93 |
|
---|
94 | buf->st_blocks = (buf->st_size-1) / buf->st_blksize + 1;
|
---|
95 |
|
---|
96 | /* Should be fixed to really fetch these values, but that
|
---|
97 | * would require calling some PRIMOS subroutines and I don't have
|
---|
98 | * a copy of the Primos Subroutine reference manuals here..
|
---|
99 | */
|
---|
100 | buf->st_atime = buf->st_mtime;
|
---|
101 | buf->st_ctime = buf->st_mtime;
|
---|
102 |
|
---|
103 | return 0;
|
---|
104 | }
|
---|
105 |
|
---|
106 | int fstat(fd, buf)
|
---|
107 | int fd;
|
---|
108 | struct stat *buf;
|
---|
109 | {
|
---|
110 | char path[1025];
|
---|
111 |
|
---|
112 | return stat(getname(fd, path), buf);
|
---|
113 | }
|
---|
114 |
|
---|
115 | int ascii2pascii(c)
|
---|
116 | int c;
|
---|
117 | {
|
---|
118 | return (c ? (c | 0x80) : '\0');
|
---|
119 | }
|
---|
120 |
|
---|
121 |
|
---|
122 | #endif /* __50SERIES */
|
---|
Note:
See
TracBrowser
for help on using the repository browser.