3 * stat.c - stat() for the netlib
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
10 #include <sys/types.h>
17 /* DOS 3.0 and MuFS extensions to file info block */
20 #include <proto/dos.h>
21 #include <proto/utility.h>
23 int stat(const char *name
, struct stat
*st
)
29 if (st
== NULL
|| ((1 & (long)st
) == 1)) {
34 lock
= Lock((STRPTR
)name
, SHARED_LOCK
);
36 if (found
= lock
!= NULL
) {
37 if (Examine(lock
, __dostat_fib
)) {
38 __dostat(__dostat_fib
, st
);
39 st
->st_dev
= (dev_t
)((struct FileLock
*)BADDR(lock
))->fl_Task
;
45 UBYTE errcode
= IoErr();
47 if (errcode
== ERROR_OBJECT_IN_USE
) {
60 int lstat(const char *name
, struct stat
*st
)
62 /* Cannot lock - do examine via Examine()/ExNext() */
66 if (st
== NULL
|| ((1 & (long)st
) == 1)) {
71 cname
= malloc(strlen(name
) + 1);
75 char *pp
= PathPart(strcpy(cname
, name
));
78 if (lock
= Lock(cname
, SHARED_LOCK
)) {
79 pp
= FilePart((STRPTR
)name
);
81 if (Examine(lock
, __dostat_fib
)) {
82 while (ExNext(lock
, __dostat_fib
)) {
83 if (Stricmp(pp
, __dostat_fib
->fib_FileName
) == 0) {
84 __dostat(__dostat_fib
, st
);
85 st
->st_dev
= (dev_t
)((struct FileLock
*)BADDR(lock
))->fl_Task
;