All Forums |
Register |
Login |
Search |
Subscriptions |
My Profile |
Inbox |
Tool Warehouse |
FAQs |
Resources |
Help |
Member List |
Address Book |
Logout |
|
|
FAQ for portability issues?
|
Logged in as: Guest |
Users viewing this topic: none |
|
Login |
|
|
FAQ for portability issues? - Sep. 18, '06, 6:25:12 PM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
Hi,
I look for a FAQ related to portability issues and how to resolve them. I think of best practice solutions which may be applied to upstream, not just getting it work. The other reason for such a FAQ would be to get an idea about what has encoutered so far as being different.
I so far saw the following problems:
1. UID 0 / root
Several shell scripts test for being root as
$ test `id -u` -eq 0
One could replace 0 by 197108, but upstream would probably reject that :-)
For C programs I found to replace the literal 0 with a #define ROOTUID, but where should such a #define actually be defined? Is there a autoconf test/definition for it?
2. configure doesn't recognize ld's shared feature
I found this one: http://www.interopsystems.com/tools/tm.aspx?m=8556#8560
But is there a more general way, i.e. use newer autoconf? Which minimum version?
3. rename(2) issue
I just found that rename(2) behaves differently on linux/freebsd/win32 on the one hand and interix 3.5 on the other. Try:
$ cd /tmp
$ touch foo
$ mkdir bar
$ perl -e 'rename "foo", "foo" or die"' # is successful on all 4 platforms
$ perl -e 'rename "bar", "bar" or die"' # dies only on interix!
(For Win32, I used cmd.exe and ActivePerl.) One could argue that one is trying to move ./bar into ./bar/bar, and therefore the failing would be correct (because of moving a tree into its own subtree). But if src and dst are the same, then it is also argueable, that rename should be a no-op and interix is broken.
(not that much a question on how to patch, but more a documentation of the issue)
4. gnulib / missing obstack.{c,h}
Interix's libc has obviously differences to glibc. Missing functions such as strnlen or obstack can be found in gnulib. But how is the best way to merge the gnulib parts? Into every package? Or (just an idea) would it be possible to build a gnulib.so providing the missing functions in such a transparent way that configure and gcc wouldn't realize that libc misses it? One could say there might be packages which handle e.g. a missing strnlen itself, so using the gnulib version might not always be the right choice, however.
Martin
|
|
|
RE: FAQ for portability issues? - Sep. 18, '06, 6:42:32 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
1) Already solved by using "libport".
2) Yes, a new set of configuration tools will do it. Most app's
don't update too often though.
3) You don't test system functionality with Perl. The rename(2) API
works the same. perhaps there is an issue with Perl, but I don't know
why there would be offhand.
4) There are parts of glibc that are not portable. Witness the crap that CVS does.
The easiest is for me to add it to libport if it's needed. This helps
track it so future Interix releases (i.e. Vista) can have it in the base.
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 3:01:46 AM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
3) I know. I thought perl would be close enough, however. Now I retested with a C program:
#include <stdio.h>
int main(void)
{
int r = rename("bar","bar");
perror("rename returns");
return r;
}
The result is the same, however: On Linux: Success, on Interix: Invalid argument.
< Message edited by mkoeppe -- Sep. 19, '06, 3:03:52 AM >
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 3:41:17 AM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
You always have perror() being called.
You have not conditionalized it on rename() returning failure.
It should be:
#include <stdio.h>
int main(void)
{
int r = rename("bar", "bar");
if (r != 0)
perror("rename returns");
return r;
}
The value errno can be left at a non EZERO value
from some previous action which include process startup.
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 9:41:06 AM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
Rodney,
the perror() call is not the problem. If conditioned or not, it is always after rename(2), so errno is always correct, i.e. related to rename(2). If unconditioned and errno==0, it prints "success".
My simple program should demonstrate that rename(2) behaves differently on Linux/FreeBSD/Win32 and Interix when "renaming" a directory to its current name, and that Perl has nothing to with it! (For the Win32 version compile my test program with cl.exe.)
I think it's at least a portability issue, if not a bug in interix.
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 11:15:30 AM
|
|
|
markfunk
Posts: 670
Joined: Mar. 31, '03,
Status: offline
|
This is definitely a bug in Interix.
If both "old" and "new" refer to the same filesystem object (eg file),
then rename() should return success and perform no other action.
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 1:36:47 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
When I run the test program then rename() does return success for 'rename("bar", "bar")'.
An API is only to set errno if an error occurs and leave it alone otherwise.
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 2:27:22 PM
|
|
|
markfunk
Posts: 670
Joined: Mar. 31, '03,
Status: offline
|
rename("bar", "bar") returns -1 for me. (If -1, errno = 22)
I'm using an NTFS filesystem, with:
$ uname -X
System = Interix
Node = mark-funk
Release = 3.5
Version = SP-8.0.1969.1
Machine = x86
Processor = Intel_x86_Family15_Model2_Stepping9
HostSystem = Windows
HostRelease = SP2
HostVersion = 5.1
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 3:03:37 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
Work on:
System = Interix
Node = squirtle
Release = 3.5
Version = SP-8.0.1969.32
Machine = x86
Processor = Intel_x86_Family15_Model2_Stepping7
HostSystem = Windows
HostRelease = SP4
HostVersion = 5.0
The current subsystem is version 8.0.1969.45 (KB921207).
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 6:52:17 PM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
Sorry Rodney, you're right. Setting errno back to EZERO on success is optional for library functions, I think I won't forget that from now on.
I use SP-8.0.1969.40 (KB917960) on W2K SP4, and that is broken. Interesting that SP-8.0.1969.1 is broken, too, but SP-8.0.1969.32 is not. As you write current is 45, how can one easily determine at any time which the most current version is? Is there a MS page about that? (I will test 45 in the next days.)
ad 4) I now had a closer look at libport. It seems exactly to be what I looked for. Unfortunately I cannot find the source for it anywhere so that I could a) have a look into it and b) change / enhance it when needed.
ad 1) Is there a shell linked against libport so that shell script tests for root or uid 0 work? What about all other packages, i.e. perl? Should there be 2 versions of each?
Martin
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 9:07:22 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
quote:
I use SP-8.0.1969.40 (KB917960) on W2K SP4, and that is broken. Interesting that SP-8.0.1969.1 is broken, too, but SP-8.0.1969.32 is not. As you write current is 45, how can one easily determine at any time which the most current version is? Is there a MS page about that? (I will test 45 in the next days.)
mmm, that's wierd. The hotfixes are supposed to be cumlative.
The hotfix KB889087 (*.20) did break something that didn't get found/fixed until
KB904781 (*.35). No hotfixes were ever explict for rename() though.
There's no specific page at MS to find out what the most current version is.
I do a search every now and then to find it. I've posted the results on a web
page at http://www.interix.ca under "bugs".
I'm going to ask an MS PM about this.
Libport is private right now for the sources.
If there are specific requests then I can add them (such as strnlen()).
I haven't linked any of the shells to libport. Several of the
libraries and applications have been (i.e. BIND, openssh). But it's
been selective parts: openssh uses everything, but BIND only
uses the extended ioctl() API.
I'm leary of linking something like id to libport since
knowing the real UID/GID is important. But the argument is compelling.
I first thought as utility options, but I think a special environment
variable being set would make a better control (then no scripts would
need to be changed and nothing would "break" unless intended).
I'll ponder on this some more (others are welcome to add comments for
or against this idea for influence ).
|
|
|
RE: FAQ for portability issues? - Sep. 19, '06, 10:10:17 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
Libport now has strnlen() starting at version 1.1.8.
Do "pkg_update -L libport" to get it.
|
|
|
RE: FAQ for portability issues? - Sep. 20, '06, 1:02:03 AM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
I realize I need to gather some more information before asking the
subsystem dev team about the rename() problem.
Do you have "case sensitive fileystems" on?
Which directory where you in when you performed the test?
When you run the test "bar" you get the error.
If you run it as 'rename("/tmp/bar", "/tmp/bar")' is the result the
same or different? (That is, with a full path).
|
|
|
RE: FAQ for portability issues? - Sep. 20, '06, 10:28:00 AM
|
|
|
markfunk
Posts: 670
Joined: Mar. 31, '03,
Status: offline
|
case-sensitivity = on
filesys info:
$ pwd
/tmp/bug-rename
$ df -k .
Filesystem 1024-blocks Used Available Capacity Type Mounted on
//HarddiskVolume1 156288320 114060260 42228060 73% ntfs /dev/fs/C
All the following fail with rename() returning -1 and errno set to EINVAL
rename("bar","bar")
rename("./bar","./bar")
rename("/tmp/bug-rename/bar","/tmp/bug-rename/bar")
|
|
|
RE: FAQ for portability issues? - Sep. 20, '06, 5:28:51 PM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
The same for me:
case-sensitive = on
I now tested with version .45, on local ntfs drive C: as well as on windows and samba netwok shares, with absolute and relative path names. I never saw a successful rename.
|
|
|
RE: FAQ for portability issues? - Sep. 20, '06, 5:35:58 PM
|
|
|
Rodney
Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
|
Maybe this has nothing to do with Interix, but with the NTFS driver
instead. Have you guys been doing the regular updates from MS?
I'm on W2K/SP4, Mark's on XP/SP2. Which are you on mkoeppe?
|
|
|
RE: FAQ for portability issues? - Sep. 21, '06, 11:24:42 AM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
I use W2K-SP4 with lastest or near to latest (i.e. as of 08/2006) patches. I did a fresh install a few days ago and only have installed SFU3.5 on this box. I don't think, it's ntfs, because with Win32's rename() it works. That's not case sensitive though.
|
|
|
RE: FAQ for portability issues? - Sep. 24, '06, 6:11:12 AM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
Hi Rodney,
I just wanted to use libport and got a link error (without libport, arc4random() is not needed):
/usr/lib//libport.a(mktemp.o)(.text+0x99):M:\Interix\src\lib: undefined reference to _arc4random'
/usr/lib//libport.a(mktemp.o)(.text+0x6e):M:\Interix\src\lib: undefined reference to _arc4random'
/usr/lib//libport.a(mktemp.o)(.text+0x6e):M:\Interix\src\lib: undefined reference to _arc4random'
So I wrote this test program and compiled without libport using
gcc -D_ALL_SOURCE test.c
#include <stdlib.h>
int main(void)
{
return arc4random();
}
But even this does not link! So: Where is arc4random()? It is at least declared in MS's /usr/include/stdlib.h.
|
|
|
RE: FAQ for portability issues? - Sep. 24, '06, 12:25:07 PM
|
|
|
mkoeppe
Posts: 46
Joined: Dec. 8, '05,
Status: offline
|
Hi Rodney,
while porting I discovered a failing
#include <inttypes.h>
1. Are there plans to add that to libport?
2. obstack.{c,h} would also be nice to have.
3. in 1.1.8 I found the strnlen symbol, but the header is not there. Is it intentional so that libport's strnlen is only used when assumed to be there and not used if there is a check for it? But then you might get warnings about an undeclared function.
|
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
|
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts |
|
|
|