[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: read-file on HP NonStop
From: |
Schmitz, Joachim |
Subject: |
RE: read-file on HP NonStop |
Date: |
Tue, 5 Oct 2010 06:31:58 +0000 |
Hi Bruno
How to differentiate an OSS from a Guardian file is documented in the manual
(up to several minutes ago I wasn't aware of this) and there are macros
available for this in in <sys/stat.h>:
#ifdef _TANDEM_SOURCE
/* Given the st_dev field (not the mode) the follow determines if a file
* is a Guardian (/G) object
*/
#define _S_GUARDIANOBJECT_MASK 0xC0000000
#define _S_GUARDIANOBJECT 0xC0000000
#define S_ISGUARDIANOBJECT(st_dev) \
(((st_dev) & _S_GUARDIANOBJECT_MASK) == _S_GUARDIANOBJECT)
#define S_ISEXPANDOBJECT(st_dev) _s_isexpandobject(st_dev)
int _s_isexpandobject(dev_t);
#endif /* _TANDEM_SOURCE */
We simply can't rely on st_size if S_ISGUARDIANOBJECT(st_dev) is true, due to
the different file semantics on these 2 personalities and the implicit
conversion of an EDIT file when being read with POSIX APIs.
So a possible fix might be:
diff -u ./test-read-file.c.orig ./test-read-file.c
--- ./test-read-file.c.orig 2010-01-31 10:29:44.000000000 -0600
+++ ./test-read-file.c 2010-10-05 01:10:30.000000000 -0500
@@ -56,6 +56,9 @@
if (len != statbuf.st_size)
{
fprintf (stderr, "Read %ld from %s...\n", (unsigned long) len,
FILE1);
+#ifdef _TANDEM_SOURCE /* HP NonStop with extensions enabled */
+ if ( !S_ISGUARDIANOBJECT(statbuf.st_dev) )
+#endif
err = 1;
}
free (out);
However, I don't believe /etc/resolv.conf to be a good file to check for,
/etc/profile is more likely to be available on every system, even those that
don't have any network connection., so another fix might be:
diff -u ./test-read-file.c.orig ./test-read-file.c
--- ./test-read-file.c.orig 2010-01-31 10:29:44.000000000 -0600
+++ ./test-read-file.c 2010-10-05 01:18:05.000000000 -0500
@@ -23,7 +23,7 @@
#include <stdlib.h>
#include <sys/stat.h>
-#define FILE1 "/etc/resolv.conf"
+#define FILE1 "/etc/profile"
#define FILE2 "/dev/null"
int
KISS...
On the other hand, I can live with that one single failing test pretty well, so
maybe no fix is needed at all?
You did add ACL support for HP NonStop, and in a very short time, and I'd like
to thank you for this a lot!
Bye, Jojo
-----Original Message-----
From: Bruno Haible [mailto:address@hidden
Sent: Tuesday, October 05, 2010 3:52 AM
To: Schmitz, Joachim
Cc: address@hidden
Subject: Re: read-file on HP NonStop
Joachim Schmitz writes:
> Doesn't work here, same problem:
> Read 68 from /etc/resolv.conf...
> FAIL: test-read-file
>
> And to clarify: the problem is not the symlink, it is the different
> personalities in NonStop. A symlink inside the OSS personality wouldn't
> be a problem, a symlink to an EDIT file in Guardian is, in respect to
> the size stat() reports.
This means, you have a problem with stat() or with the S_ISREG macro.
In Unix, when S_ISREG of a file is true, then you should be able to read
exactly as many bytes from the file as stat() returned in the st_size.
Therefore on NonStop Kernel, so that stat() and S_ISREG works on all files,
one of the following needs to be done:
a) stat() needs to be fixed or wrapped, so that it sets the st_size
to 68 instead of 2144 in said situation.
b) stat() needs to be fixed or wrapped, so that it sets the st_mode
field to a value for which S_ISREG returns 0.
c) S_ISREG needs to be fixed or replaced, so that it returns 0 when
given as argument the st_mode value from an statbuf for said file.
Bruno
- RE: ACLs on HP NonStop, (continued)
- RE: ACLs on HP NonStop, Schmitz, Joachim, 2010/10/03
- Re: ACLs on HP NonStop, Bruno Haible, 2010/10/03
- RE: ACLs on HP NonStop, Schmitz, Joachim, 2010/10/03
- Re: ACLs on HP NonStop, Bruno Haible, 2010/10/03
- Re: read-file on HP NonStop, Bruno Haible, 2010/10/03
- RE: read-file on HP NonStop, Schmitz, Joachim, 2010/10/04
- Re: read-file on HP NonStop, Paolo Bonzini, 2010/10/04
- RE: read-file on HP NonStop, Schmitz, Joachim, 2010/10/04
- Re: read-file on HP NonStop, Bruno Haible, 2010/10/04
- Message not available
- Re: read-file on HP NonStop, Bruno Haible, 2010/10/04
- RE: read-file on HP NonStop,
Schmitz, Joachim <=
- Re: read-file on HP NonStop, Pádraig Brady, 2010/10/05
- RE: ACLs on HP NonStop, Schmitz, Joachim, 2010/10/03
- Re: ACLs on HP NonStop, Bruno Haible, 2010/10/03
- RE: ACLs on HP NonStop, Schmitz, Joachim, 2010/10/03
- Message not available
- RE: ACLs on HP NonStop, Schmitz, Joachim, 2010/10/03