Patch #: 95 Type: operational change Priority: none Modification: allow AUFS copying across file systems Submitted: Mark Abbott Archived: munnari.OZ.AU mac/cap.patches/cap60.patch095 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch095' Summary: add xdev_rename() function File: cap60/Configure File: cap60/applications/aufs/afpos.c *** Configure.orig Sun Mar 8 14:34:06 1992 --- Configure Sun Mar 8 14:42:33 1992 *************** *** 1,7 **** #!/bin/sh ! # $Author: djh $ $Date: 1992/03/07 12:22:53 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.38 1992/03/07 12:22:53 djh Rel djh $ ! # $Revision: 2.38 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # --- 1,7 ---- #!/bin/sh ! # $Author: djh $ $Date: 1992/03/08 04:42:23 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.39 1992/03/08 04:42:23 djh Rel djh $ ! # $Revision: 2.39 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # *************** *** 613,618 **** --- 613,621 ---- # # + PASS_THRU pass through LWSRV jobs with no adobe preprocessing (for PCs) # define(`specialcflags',concat(specialcflags,` -DPASS_THRU')) + # + # + XDEV_RENAME allow files to be moved over cross device links + # define(`specialcflags',concat(specialcflags,` -DXDEV_RENAME')) # # # *** applications/aufs/afpos.c.orig Thu Feb 20 21:32:53 1992 --- applications/aufs/afpos.c Sun Mar 8 14:32:42 1992 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1992/02/20 10:32:42 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.21 1992/02/20 10:32:42 djh Rel djh $ ! * $Revision: 2.21 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1992/03/08 04:32:12 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.22 1992/03/08 04:32:12 djh Rel djh $ ! * $Revision: 2.22 $ */ /* *************** *** 328,333 **** --- 328,336 ---- private OSErr unix_rmdir(); private OSErr unix_unlink(); private OSErr unix_rename(); + #ifdef XDEV_RENAME + private OSErr xdev_rename(); /* rename across devices */ + #endif XDEV_RENAME private OSErr unix_open(); private OSErr unix_close(); private OSErr unix_mkdir(); *************** *** 3359,3373 **** #ifdef aux if (strcmp(from, to) == 0) return(noErr); ! #endif if (rename(from,to) == 0) return(noErr); if (DBUNX) printf("unix_rename: failed %s\n",syserr()); - return(ItoEErr(errno)); } private OSErr unix_open(path,mode,fd) --- 3362,3452 ---- #ifdef aux if (strcmp(from, to) == 0) return(noErr); ! #endif aux if (rename(from,to) == 0) return(noErr); + #ifdef XDEV_RENAME + return(xdev_rename(from,to)); + #else XDEV_RENAME if (DBUNX) printf("unix_rename: failed %s\n",syserr()); return(ItoEErr(errno)); + #endif XDEV_RENAME } + + #ifdef XDEV_RENAME + private OSErr + xdev_rename(from,to) + char *from, *to; + { + struct stat fstb, tstb; + int err, mode, ffd, tfd; + + if (DBUNX) + printf("xdev_rename: from %s to %s\n",from,to); + + if ((err = unix_stat(from,&fstb)) != noErr) + return(ItoEErr(errno)); + + /* if "from" is a directory, recursively copy it */ + if (S_ISDIR(fstb.st_mode)) { + #ifdef USEDIRENT + struct dirent *dinfp, *readdir(); + #else USEDIRENT + struct direct *dinfp, *readdir(); + #endif USEDIRENT + char fname[MAXPATHLEN]; + char tname[MAXPATHLEN]; + char *fend, *tend; + DIR *dptr; + + if (DBUNX) + printf("xdev_rename: copying directory ...\n"); + + /* Create a destination directory with same owner, group */ + if ((err = unix_mkdir(to,fstb.st_mode)) != noErr) + return(err); + if ((err = unix_chown(to,fstb.st_uid,fstb.st_gid)) != noErr) + return(err); + + /* Read each item in the "from" dir and recurse to move it */ + if ((dptr = opendir(from)) == NULL) + return(ItoEErr(errno)); + + fend = fname + strlen(strcpy(fname,from)); + tend = tname + strlen(strcpy(tname,to)); + *fend++ = '/'; + *tend++ = '/'; + + for (dinfp = readdir(dptr); dinfp != NULL; dinfp = readdir(dptr)) { + if (*dinfp->d_name == '.') + if ((dinfp->d_namlen == 1) || + ((dinfp->d_namlen == 2) && (*(dinfp->d_name+1) == '.'))) + continue; + *fend = *tend = '\0'; + strcat(fname,dinfp->d_name); + strcat(tname,dinfp->d_name); + if ((err = xdev_rename(fname,tname)) != noErr) { + if (DBUNX) + printf("xdev_rename: copy failed %s\n",syserr()); + closedir(dptr); + return(err); + } + } + closedir(dptr); + + /* Finally, remove the directory */ + return(unix_rmdir(from)); + } else { + if ((err = os_copy(from,to,fstb.st_mode)) != noErr) + return(ItoEErr(err)); + + /* Remove the copied file */ + return(unix_unlink(from)); + } + } + #endif XDEV_RENAME private OSErr unix_open(path,mode,fd) *** README.orig Sun Mar 8 14:33:09 1992 --- README Sun Mar 8 14:33:32 1992 *************** *** 3,9 **** (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 94, March 1992 Introduction ------------ --- 3,9 ---- (For use with AppleTalk/Ethernet bridge) o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 95, March 1992 Introduction ------------