Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!ncar!ames!mindcraft.com!karish From: karish@mindcraft.com (Chuck Karish) Newsgroups: comp.unix.aix Subject: Re: It works everywhere else, but not on AIX Summary: It doesn't work everywhere Message-ID: <671974713.17002@mindcraft.com> Date: 18 Apr 91 11:38:32 GMT References: <1991Apr15.182214.10391@ux1.cso.uiuc.edu> Organization: Mindcraft, Inc. Lines: 36 In article <1991Apr15.182214.10391@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes: >First of all, the "df" command does not always know how to find the file >system a particular path name it is given is on [ ... ] > >So apparently I need some other way to find out the file system I am on >that is also portable over other UNIX platforms. Until AIX, that was "df" >itself. This method has never been portable. AIX 2.2.1 is based on SVR2, which, I believe, did not support the desired behavior. SCO UNIX doesn't support it. A/UX 1.2 lets the administrator decide which filesystems are reported by df, so it won't work reliably there, either. How to do this portably? Write a program that calls stat() and uses the major and minor device numbers to figure out which of the filesystems returned by mount(8) is the right one. If you want to do it all in a shell script, use cpio (portability warning! it's not everywhere) to save the directory, and read out the major and minor numbers with dd. Schemes based on comparing the prefix from `pwd` to mount(8) output can be fooled by symbolic links. >Second thing. I have a few programs that were written with direct system >calls rather that C library calls, for I/O. These programs work on all my >other UNIX platforms but do not work on AIX. Get back to us on this one when you have a question. read() and write() work fine for me on AIX. I've compiled a number of imported programs on AIX with little porting work needed, and no special consideration for read() and write() on regular files. Chuck Karish karish@mindcraft.com Mindcraft, Inc. (415) 323-9000