home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ahmcs!alan
- From: alan@ahmcs.mq.com (Alan Mintz)
- Newsgroups: comp.unix.xenix.sco
- Subject: dirent and strerror problems in SCO XENIX 2.3?
- Message-ID: <466@ahmcs.mq.com>
- Date: 24 Jul 92 06:40:31 GMT
- Organization: Micro-Quick Systems, Inc.
- Lines: 81
-
- I have encountered a couple of oddities while building Taylor-uucp for
- SCO XENIX 2.3.
-
- For some reason, in the routines that scan directories for work, the
- d_name field in dirent structures seems to start 2 bytes too far into
- the structure, chopping off the first two chars of the filename. I
- have a hunch that it has to do with the d_off field being of the
- wrong type (off_t, which is a long, instead of short).
-
- For example:
-
- ************************************************
- #include <sys/types.h>
- #include <stdio.h>
- #include <dirent.h>
-
- main()
- {
- DIR *topdir;
- struct dirent *entry;
- int i;
-
- topdir=opendir((char *) ".");
-
- for(i=1;i<5;i++)
- {
- entry=readdir(topdir);
- printf("Inode: %11d Offset: %11d RecLen: %11d Name: %s\n",
- entry->d_ino, entry->d_off, entry->d_reclen, entry->d_name);
- }
- }
- ************************************************
-
- yields chopped off filenames, whereas :
-
- ************************************************
-
- #include <stdio.h>
-
- typedef struct
- {
- int dd_fd; /* file descriptor */
- int dd_loc; /* offset in block */
- int dd_size; /* amount of valid data */
- char *dd_buf; /* directory block */
- } DIR; /* stream data from opendir() */
-
- struct dirent {
- long d_ino; /* inode number of entry */
- unsigned short d_off; /* offset of disk direntory entry */
- unsigned short d_reclen; /* length of this record */
- char d_name[1]; /* name of file */
- };
-
- main()
- {
- DIR *topdir;
- struct dirent *entry;
- int i;
-
- topdir=opendir((char *) ".");
-
- for(i=1;i<5;i++)
- {
- entry=readdir(topdir);
- printf("Inode: %11d Offset: %11d RecLen: %11d Name: %s\n",
- entry->d_ino, entry->d_off, entry->d_reclen, entry->d_name);
- }
- }
- ************************************************
-
- seems to work correctly. What gives here? Is sys/dirent.h wrong?
-
-
- Also, has anyone had trouble with the strerror macro in string.h under
- gcc? I get unexplainable "parse errors" when using it, yet, in looking
- at the output of cpp, all looks normal. What am I missing?
- ---
- < Alan H. Mintz | alan@ahmcs.mq.com | ...!uunet!ahmcs!alan >
- --
- < Alan H. Mintz | alan@ahmcs.mq.com | ...!uunet!ahmcs!alan >
-