#include <sys/types.h>
#include <fcntl.h>
#include "ourhdr.h"
int main(int argc, char *argv[])
{
int accmode, val;
if (argc != 2) ... /* fel */
if ( (val = fcntl(atoi(argv[1]), F_GETFL, 0)) < 0) ... /* fel */
accmode = val & O_ACCMODE;
if (accmode == O_RDONLY) printf("read only");
else if (accmode == O_WRONLY) printf("write only");
else if (accmode == O_RDWR) printf("read write");
else err_dump("unknown access mode");
if (val & O_APPEND) printf(", append");
if (val & O_NONBLOCK) printf(", nonblocking");
#if !defined(_POSIX_SOURCE) && defined(O_SYNC)
if (val & O_SYNC) printf(", synchronous writes");
#endif
putchar('\n');
exit(0);
}
/* En förenklad version av struct stat */
struct stat {
mode_t st_mode; /* Filtyp/mode */
ino_t st_ino; /* I-nodsnummer */
nlink_t st_nlink; /* Antal länkar */
uid_t st_uid; /* Ägarens anv.-ID */
gid_t st_gid; /* Ägarens grupp-ID */
off_t st_size; /* Storlek i byte */
time_t st_atime; /* Senast filen rördes */
time_t st_mtime; /* Senaste ändring */
time_t st_ctime; /* Senaste statusändring */
};
[an error occurred while processing this directive]