* stat() problems.
@ 2002-08-01 7:56 Stefanos Koutsoutos
2002-08-01 11:48 ` Alexandre P. Nunes
0 siblings, 1 reply; 6+ messages in thread
From: Stefanos Koutsoutos @ 2002-08-01 7:56 UTC (permalink / raw)
To: linux-gcc
Hi,
I'm facing problems with stat() system call. It seems that it follows
filesystem links! To be more accurate I try:
struct stat buf;
stat("this_is_a_link", &buf);
and then: S_ISLNK( buf.st_mode ) is false!
More, the mode is the same as the mode of the file it links to! I think
that this is not what it supposed to be done by stat(). Any ideas??
Thanks in advance.
Stefanos.
--
____________________
Stefanos Koutsoutos
Developer
MD5 S.A.
koutsoutos@md5sa.com
www.md5sa.com
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: stat() problems.
2002-08-01 7:56 stat() problems Stefanos Koutsoutos
@ 2002-08-01 11:48 ` Alexandre P. Nunes
2002-08-01 12:05 ` Stefanos Koutsoutos
2002-08-28 20:50 ` C Language Reference for @ and : Nate
0 siblings, 2 replies; 6+ messages in thread
From: Alexandre P. Nunes @ 2002-08-01 11:48 UTC (permalink / raw)
To: linux-gcc
Stefanos Koutsoutos wrote:
>Hi,
>
>I'm facing problems with stat() system call. It seems that it follows
>filesystem links! To be more accurate I try:
>
>struct stat buf;
>stat("this_is_a_link", &buf);
>
>and then: S_ISLNK( buf.st_mode ) is false!
>
>More, the mode is the same as the mode of the file it links to! I think
>that this is not what it supposed to be done by stat(). Any ideas??
>
>Thanks in advance.
>Stefanos.
>
>
>
stat() follows symlinks. That's why there's lstat(), try it instead.
Cheers,
Alexandre
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: stat() problems.
2002-08-01 11:48 ` Alexandre P. Nunes
@ 2002-08-01 12:05 ` Stefanos Koutsoutos
2002-08-28 20:50 ` C Language Reference for @ and : Nate
1 sibling, 0 replies; 6+ messages in thread
From: Stefanos Koutsoutos @ 2002-08-01 12:05 UTC (permalink / raw)
To: linux-gcc
Thanks a lot Alexandre!
On Thu, 2002-08-01 at 14:48, Alexandre P. Nunes wrote:
>
> stat() follows symlinks. That's why there's lstat(), try it instead.
>
> Cheers,
>
>
--
____________________
Stefanos Koutsoutos
Developer
MD5 S.A.
koutsoutos@md5sa.com
www.md5sa.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* C Language Reference for @ and :
2002-08-01 11:48 ` Alexandre P. Nunes
2002-08-01 12:05 ` Stefanos Koutsoutos
@ 2002-08-28 20:50 ` Nate
2002-08-28 22:16 ` Stephen Satchell
1 sibling, 1 reply; 6+ messages in thread
From: Nate @ 2002-08-28 20:50 UTC (permalink / raw)
To: linux-gcc
I am looking at some C code and I cannot find any language reference as to
what the '@' symbol or token means...
For, example, from the header file I am trying to interpret....
/////////////////////////////////////////////////////////////////
static unsigned char P1 @ 0x90;
static unsigned char P2 @ 0xA0;
static unsigned char P3 @ 0xB0;
/////////////////////////////////////////////////////////////////
Also what does these colons mean... ( I understand this is creating a new
type and it is a "public by default" class for a bit watching type.) But
what does the colon do? Initialize defualts?
/////////////////////////////////////////////////////////////////
typedef struct
{
unsigned B0:1;
unsigned B1:1;
unsigned B2:1;
unsigned B3:1;
unsigned B4:1;
unsigned B5:1;
unsigned B6:1;
unsigned B7:1;
} SFR;
/////////////////////////////////////////////////////////////////
Thanks,
Nate
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: C Language Reference for @ and :
2002-08-28 20:50 ` C Language Reference for @ and : Nate
@ 2002-08-28 22:16 ` Stephen Satchell
2003-01-15 20:00 ` Stack and Heap Nate
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Satchell @ 2002-08-28 22:16 UTC (permalink / raw)
To: Nate, linux-gcc
At 01:50 PM 8/28/02 -0700, Nate wrote:
>I am looking at some C code and I cannot find any language reference as to
>what the '@' symbol or token means...
>
>For, example, from the header file I am trying to interpret....
>
>/////////////////////////////////////////////////////////////////
>static unsigned char P1 @ 0x90;
>static unsigned char P2 @ 0xA0;
>static unsigned char P3 @ 0xB0;
>/////////////////////////////////////////////////////////////////
The compiler implements an extension that indicates that the unsigned char
P1 is at the absolute address 0x00000090, and when the compiler generates
an access it should use this absolute address. The equivalent ANSI C code
using pointer variables might be:
static unsigned char * const P1 = (unsigned char *) 0x90;
static unsigned char * const P2 = (unsigned char *) 0xA0;
static unsigned char * const P3 = (unsigned char *) 0xB0;
Or the other way to do this is to use the preprocessor:
#define P1 ((unsigned char *)(0x90));
#define P2 ((unsigned char *)(0xA0));
#define P3 ((unsigned char *)(0xB0));
I used to see this with some compilers for machines that had memory-mapped
I/O in which the registers were at hardware-fixed locations. This is
actually bad form, particularly when a driver can be used with multiple
devices and there was no way to "map in" the particular device interface.
This is an oldie, and VERY machine-dependent.
>Also what does these colons mean... ( I understand this is creating a new
>type and it is a "public by default" class for a bit watching type.) But
>what does the colon do? Initialize defualts?
>
>/////////////////////////////////////////////////////////////////
>typedef struct
>{
> unsigned B0:1;
> unsigned B1:1;
> unsigned B2:1;
> unsigned B3:1;
> unsigned B4:1;
> unsigned B5:1;
> unsigned B6:1;
> unsigned B7:1;
>} SFR;
>/////////////////////////////////////////////////////////////////
Bitfield definition. Page 136-138 in the first edition of K&R _The C
Programming Language_, 149-150 in the second edition. This is part of ANSI
C, but the implementation definition makes it a non-portable
construct. Some people like to try to use bitfields in networking, with
disastrous results as you change compilers or even versions of the same
compiler.
The colon introduces a bit-width. In your definition, you are defining
seven bits in the variable SFR to be one-bit values that can be set or
reset using a simple assignment statement:
SFR.B0 = 1; /* Set a single bit */
SFR.B4 = 0; /* Reset a single bit */
The problem is that which structure variables get assigned to which bits is
not specified in the standard, but is labelled "implementation
defined." From the definition you show, I suspect that the compiler
originally used to compile the code assigned bit fields from the low-order
bits to the high-order bits of a regular integer. Other compilers may
start from the most significant bit and work down, which is why this
construct is highly non-portable if you store or read the variable to/from
storage or a network.
Satch
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-01-15 20:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-01 7:56 stat() problems Stefanos Koutsoutos
2002-08-01 11:48 ` Alexandre P. Nunes
2002-08-01 12:05 ` Stefanos Koutsoutos
2002-08-28 20:50 ` C Language Reference for @ and : Nate
2002-08-28 22:16 ` Stephen Satchell
2003-01-15 20:00 ` Stack and Heap Nate
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).