mjy@sdti.UUCP (Michael J. Young) (12/09/87)
After running into some problems with cpio on my Microport system, I decided to finally give Mark Brukhartz's afio program a try. I was pleasantly surprised to find that it not only does not suffer from cpio's limitation on archive size (cpio as distributed by Microport seems to have problems on archives over about 16 megabytes), but it's a little bit faster as well. So it quickly replaced cpio as my preferred method of doing backups. However, I think I discovered a minor bug (the hard way!): When doing backups, I use the following command: find . -depth -print | afio .... (The -depth argument is recommended by Microport in their manual). This causes afio to archive directories AFTER their files, as expected. Unfortunately, when restoring such an archive, these directories are restored with the wrong owner and group, even if I use the -x flag! I had the pleasure of restoring an entire file system the other day, only to find out that all subdirectories of /usr had root,sys ownership! I first noticed it when news started dropping all incoming messages on the floor! The problem seems to be that openo() does not change the directory owner/group if the directory already exists. I made the following changes to correct the situation. I make no claims for the accuracy or completeness of my solution, but it seems to work the way I expect it to now. *** afio.c.orig Tue Dec 8 16:08:48 1987 --- afio.c Tue Dec 8 16:36:25 1987 *************** *** 1711,1716 reg int fd; reg ushort perm; ushort operm; Path *path; auto Stat osb; #ifdef S_IFLNK --- 1711,1718 ----- reg int fd; reg ushort perm; ushort operm; + ushort ouid; + ushort ogid; Path *path; auto Stat osb; #ifdef S_IFLNK *************** *** 1750,1755 linkalso(linkp, name); } perm = asb->sb_mode & (xflag ? S_IPERM : S_IPOPN); switch (asb->sb_mode & S_IFMT) { case S_IFBLK: case S_IFCHR: --- 1752,1761 ----- linkalso(linkp, name); } perm = asb->sb_mode & (xflag ? S_IPERM : S_IPOPN); + if (exists){ + ouid = osb.sb_uid; + ogid = osb.sb_gid; + } switch (asb->sb_mode & S_IFMT) { case S_IFBLK: case S_IFCHR: *************** *** 1773,1778 case S_IFDIR: if (exists) if (perm != operm && chmod(name, perm) < 0) return (warn(name, syserr())); else ; --- 1779,1787 ----- case S_IFDIR: if (exists) if (perm != operm && chmod(name, perm) < 0) + return (warn(name, syserr())); + else if (xflag && (asb->sb_uid != ouid || asb->sb_gid != ogid) && + chown(name, asb->sb_uid, asb->sb_gid) < 0) return (warn(name, syserr())); else ; -- Mike Young - Software Development Technologies, Inc., Sudbury MA 01776 UUCP : {decvax,harvard,linus,mit-eddie}!necntc!necis!mrst!sdti!mjy Internet : mjy%sdti.uucp@harvard.harvard.edu Tel: +1 617 443 5779 "What would you do with a brain if you had one?" -- Dorothy, Wiz of Oz