summaryrefslogtreecommitdiffstats
path: root/usr.sbin/lpr/common_source
diff options
context:
space:
mode:
authorgad <gad@FreeBSD.org>2003-06-12 03:49:40 +0000
committergad <gad@FreeBSD.org>2003-06-12 03:49:40 +0000
commitfec999e0c4ca3b376ad8a24415f8ea6f09c64ac3 (patch)
tree805448bd31d7f4f3d80b5955c703c8ddeaf21b61 /usr.sbin/lpr/common_source
parent6865f1d753b47b47bb23a809b4f393cc7e3b3e38 (diff)
downloadFreeBSD-src-fec999e0c4ca3b376ad8a24415f8ea6f09c64ac3.zip
FreeBSD-src-fec999e0c4ca3b376ad8a24415f8ea6f09c64ac3.tar.gz
Minor improvement to some debugging code that is probably used by no one
but me (it's usually #ifdef-ed out). MFC after: 1 week
Diffstat (limited to 'usr.sbin/lpr/common_source')
-rw-r--r--usr.sbin/lpr/common_source/ctlinfo.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/usr.sbin/lpr/common_source/ctlinfo.c b/usr.sbin/lpr/common_source/ctlinfo.c
index 78b1de7..0445065 100644
--- a/usr.sbin/lpr/common_source/ctlinfo.c
+++ b/usr.sbin/lpr/common_source/ctlinfo.c
@@ -670,12 +670,23 @@ ctl_renametf(const char *ptrname, const char *tfname)
size1 = tfstat.st_size;
tfstat.st_size = 2; /* certainly invalid value */
res = stat(tfname2, &tfstat);
- /* if the sizes do not match, or either stat call failed,
- * then do not remove the temp files, but return "all OK".
- * This is just so I can see what this routine had changed.
+ /*
+ * If the sizes do not match, or either stat call failed,
+ * then do not remove the temp files, but just move them
+ * out of the way. This is so I can see what this routine
+ * had changed (and the files won't interfere with some
+ * later job coming in from the same host). In this case,
+ * we don't care if we clobber some previous file.
*/
- if (size1 != tfstat.st_size)
+ if (size1 != tfstat.st_size) {
+ strlcpy(cfname2, tfname, sizeof(cfname2));
+ strlcat(cfname2, "._T", sizeof(cfname2));
+ rename(tfname, cfname2);
+ strlcpy(cfname2, tfname2, sizeof(cfname2));
+ strlcat(cfname2, "._T", sizeof(cfname2));
+ rename(tfname2, cfname2);
return NULL;
+ }
}
#endif
unlink(tfname);
OpenPOWER on IntegriCloud