ppc64 cross-compiler on iSeries and stat()
Justin Banks
justinb at constantdata.com
Sat Mar 27 13:01:11 EST 2004
Hello -
Consider the following program :
#include <stdlib.h>
#include <sys/stat.h>
int
main(int argc, char *argv[])
{
struct stat sb;
if (stat(argv[1], &sb) == 0) {
printf("File '%s' ", argv[1]);
if (S_ISDIR(sb.st_mode))
printf("is a directory\n");
else if (S_ISREG(sb.st_mode))
printf("is a regular file\n");
else
printf("has mode %ld\n", sb.st_mode);
}
return (0);
}
[root at PW840L02 root]# gcc foo.c -o foo
[root at PW840L02 root]# ./foo Mail
File 'Mail' is a directory
[root at PW840L02 root]# ./foo hwlist.txt
File 'hwlist.txt' is a regular file
All is well. however,
[root at PW840L02 root]# powerpc64-linux-gcc foo.c -o foo
[root at PW840L02 root]# ./foo Mail
File 'Mail' has mode 0
[root at PW840L02 root]# ./foo hwlist.txt
File 'hwlist.txt' has mode 0
[root at PW840L02 root]# ls -ld Mail hwlist.txt
drwx------ 7 root root 4096 Feb 3 06:07 Mail
-rw-r--r-- 1 root root 18250 Apr 7 2003 hwlist.txt
gdb confirms this odd (to me) behaviour.
For reasons I won't go into here, I must compile with the cross compiler.
Unfortunately, I also need to call stat().
Any ideas?
-justinb
--
Justin Banks
Constant Data, Inc.
http://www.constantdata.com
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list