Research V7 development
[unix-history] / usr / src / libc / v6 / stat.c
CommitLineData
6b23496e
DR
1#include <sys/types.h>
2#include <sys/stat.h>
3
4struct ostat {
5 short os_dev;
6 short os_inum;
7 short os_flags;
8 char os_nlinks;
9 char os_uid;
10 char os_gid;
11 char os_size0;
12 short os_size1;
13 short os_addr[8];
14 long os_actime;
15 long os_modtime;
16} osbuf;
17
18stat(name, buf)
19char *name;
20struct stat *buf;
21{
22 if (syscall(18, 0, 0, name, &osbuf, 0) < 0)
23 return(-1);
24
25 stcopyit(buf);
26 return(0);
27}
28
29fstat(fd, buf)
30int fd;
31struct stat *buf;
32{
33 if (syscall(28, fd, 0, &osbuf, 0, 0) < 0)
34 return(-1);
35 stcopyit(buf);
36 return(0);
37}
38
39static
40stcopyit(buf)
41struct stat *buf;
42{
43 buf->st_dev = osbuf.os_dev;
44 buf->st_ino = osbuf.os_inum;
45 buf->st_mode = osbuf.os_flags;
46 buf->st_mode &= 067777;
47 if ((buf->st_mode&060000) == 0)
48 buf->st_mode |= 0100000;
49 buf->st_nlink = osbuf.os_nlinks;
50 buf->st_uid = osbuf.os_uid;
51 buf->st_gid = osbuf.os_gid;
52 buf->st_rdev = 0;
53 buf->st_size = ( (long) osbuf.os_size0 << 16) | osbuf.os_size1;
54 buf->st_atime = osbuf.os_actime;
55 buf->st_mtime = osbuf.os_modtime;
56 buf->st_ctime = buf->st_mtime;
57}