[comp.unix.wizards] changing "stat"

rta@pixar.UUCP (Rick Ace) (09/04/88)

In article <8424@smoke.ARPA>, gwyn@smoke.ARPA (Doug Gwyn ) writes:
# In article <66800@sun.uucp> guy@gorodish.Sun.COM (Guy Harris) writes:
# >Yes, changing the "stat" structure may be painful.  Not changing it may be
# >painful as well....
# 
# A reasonable way to make the change is to introduce a new system call,
# which acts the way one wants (e.g. long st_ino), change the C library
# stat() interface to use the new system call (and change the stat.h
# header at the same time!), then recompile and test all the system
# software at one's leisure.  Old binaries keep working until one is
# finished checking everything out and removes the old system call (if
# ever; usually it is left enabled so customers don't have to recompile
# anything).  Old binaries can fail on long inode numbers, but this is
# no worse than not making the change, and at least the official system
# software has been upgraded to work right.

If you try this, be sure to BLOW AWAY AND RECOMPILE all old .o files,
because they expect to get the old stat structure back, and if you link
them up with the new stat() in libc.a, they will get something other
than what they are expecting; if the new struct stat is larger than
the old one, memory following the structure will be mysteriously
trashed, most likely leading to lots of head-scratching.

Rick Ace
Pixar
3240 Kerner Blvd, San Rafael CA 94901
...!{sun,ucbvax}!pixar!rta

meissner@xyzzy.UUCP (Michael Meissner) (09/05/88)

In article <2381@pixar.UUCP> rta@pixar.UUCP (Rick Ace) writes:
	/* stuff about changing stat and old programs continue to work */
| If you try this, be sure to BLOW AWAY AND RECOMPILE all old .o files,
| because they expect to get the old stat structure back, and if you link
| them up with the new stat() in libc.a, they will get something other
| than what they are expecting; if the new struct stat is larger than
| the old one, memory following the structure will be mysteriously
| trashed, most likely leading to lots of head-scratching.

Actually it doesn't.  Since calling stat requires you to include
sys/stat.h, you can make both old programs and old .o files work.
Basically, there would be a macro "stat" which gets mapped to say
"_stat2" in the new stat.h that references a new name.  The library
would have both entry points.  Old .o's would go to the old name
"stat", and new ones would go to "_stat2".  Ie:

	#define	stat	_stat2

-- 
Michael Meissner, Data General.

Uucp:	...!mcnc!rti!xyzzy!meissner
Arpa:	meissner@dg-rtp.DG.COM   (or) meissner%dg-rtp.DG.COM@relay.cs.net