it`s a bug or a feature ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[ file test.c ]

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <time.h>
#include <ctype.h>
#include <dirent.h>
#include <syslog.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/file.h>
#include <sys/stat.h>
/* FREEBSD */
#ifndef HAVE_STRNLEN
size_t strnlen(char *s, size_t maxlen)
{
size_t i;
for (i=0;i<maxlen && *s != '\0';i++,s++);
return i;
}
#endif

int main(int argc, char *argv[])
{
DIR *who;
struct dirent * ent;
who = opendir("."); // open current dir
if (who) {
while (0 != (ent = readdir(who))) {
if(!strncmp(ent->d_name,".",1) || !strncmp(ent->d_name,"..",2)) {
continue;
} else {
if(ent->d_type==4) {
printf("type (%i) - dir (%s)\n",ent->d_type,ent->d_name);
} else if(ent->d_type==8) {
printf("type (%i) - file (%s)\n",ent->d_type,ent->d_name);
} else if(ent->d_type==10) {
printf("type (%i) - link (%s)\n",ent->d_type,ent->d_name);
} else {
printf("type (%i) - unused (%s)\n",ent->d_type,ent->d_name);
}
}
}
closedir(who);
}
return 0;
}

[file Makefile]

CC=gcc
CFLAGS = -O2 -Wall -D_GNU_SOURCE -DHAVE_STRNLEN
LFLAGS = -static
OBJS = test.o
SRCS = test.c

.c.o:
$(CC) $(CFLAGS) -c $<

all: test

clean:
/bin/rm -rf *.o test
########


test: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LFLAGS) -o $@
strip test

$(OBJS): Makefile
test.o: test.c

[compile output]
core:/tmp/fedora# make
gcc -O2 -Wall -D_GNU_SOURCE -DHAVE_STRNLEN -c test.c
gcc -O2 -Wall -D_GNU_SOURCE -DHAVE_STRNLEN test.o -static -o test
strip test
core:/tmp/fedora# ls -la
insgesamt 446
drwxr-xr-x 3 root root 1024 2006-11-02 23:34 .
drwxrwxrwt 6 root root 2048 2006-11-02 23:34 ..
drwxr-xr-x 2 root root 1024 2006-11-02 23:14 dir1
lrwxrwxrwx 1 root root 4 2006-11-02 23:15 dir2 -> dir1
-rw-r--r-- 1 root root 283 2006-11-02 23:11 Makefile
-rwxr-xr-x 1 root root 445984 2006-11-02 23:34 test
-rw-r--r-- 1 root root 1134 2006-11-02 23:14 test.c
-rw-r--r-- 1 root root 1380 2006-11-02 23:34 test.o

debian3.1/ suse10(x64) / freebsd says:

core:/tmp/fedora# ./test
type (8) - file (Makefile)
type (8) - file (test.c)
type (4) - dir (dir1)
type (10) - link (dir2)
type (8) - file (test.o)
type (8) - file (test)

but fc4 (x64) says:
uname -a
Linux dev 2.6.11-1.1369_FC4smp #1 SMP Thu Jun 2 23:16:33 EDT 2005 x86_64 x86_64 x86_64 GNU/Linux
./test
type (0) - unused (Makefile)
type (0) - unused (test.c)
type (0) - unused (dir1)
type (0) - unused (dir2)
type (0) - unused (test.o)
type (0) - unused (test)

strange :/

any comments aviable ?

/mfg tcmdk
http://ircDB.eu



[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux