--------------------- PatchSet 6546 Date: 2005/03/26 01:46:24 Author: hno Branch: lfs-2_5 Tag: (none) Log: Fix new swap log header Members: src/fs/aufs/store_dir_aufs.c:1.23.6.9.8.7->1.23.6.9.8.8 src/fs/diskd/store_dir_diskd.c:1.32.6.8.16.6->1.32.6.8.16.7 src/fs/ufs/store_dir_ufs.c:1.21.6.10.8.6->1.21.6.10.8.7 Index: squid/src/fs/aufs/store_dir_aufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/aufs/store_dir_aufs.c,v retrieving revision 1.23.6.9.8.7 retrieving revision 1.23.6.9.8.8 diff -u -r1.23.6.9.8.7 -r1.23.6.9.8.8 --- squid/src/fs/aufs/store_dir_aufs.c 25 Mar 2005 11:54:19 -0000 1.23.6.9.8.7 +++ squid/src/fs/aufs/store_dir_aufs.c 26 Mar 2005 01:46:24 -0000 1.23.6.9.8.8 @@ -375,7 +375,7 @@ rb->log = NULL; } else { debug(47, 1) ("Done scanning %s (%d entries)\n", - rb->sd->path, rb->n_read); + rb->sd->path, rb->counts.scancount); } store_dirs_rebuilding--; storeAufsDirCloseTmpSwapLog(rb->sd); @@ -1155,9 +1155,9 @@ hd.hdr.op = SWAP_LOG_VERSION; hd.hdr.version = 1; hd.hdr.record_size = sizeof(storeSwapLogData); - if (write(2, &hd, sizeof(hd)) != sizeof(hd)) { + if (write(fd, &hd, sizeof(hd)) != sizeof(hd)) { debug(50, 1) ("%s: %s\n", new_path, xstrerror()); - fatal("storeDirOpenTmpSwapLog: Failed to write swap log."); + fatal("storeDirOpenTmpSwapLog: Failed to write swap log header."); } aioinfo->swaplog_fd = fd; /* open a read-only stream of the old log */ @@ -1203,6 +1203,10 @@ storeAufsDirWriteCleanStart(SwapDir * sd) { struct _clean_state *state = xcalloc(1, sizeof(*state)); + union { + storeSwapLogHeader hdr; + storeSwapLogData _data; + } hd; #if HAVE_FCHMOD struct stat sb; #endif @@ -1219,6 +1223,14 @@ xfree(state); return -1; } + memset(&hd, 0, sizeof(hd)); + hd.hdr.op = SWAP_LOG_VERSION; + hd.hdr.version = 1; + hd.hdr.record_size = sizeof(storeSwapLogData); + if (write(state->fd, &hd, sizeof(hd)) != sizeof(hd)) { + debug(50, 1) ("%s: %s\n", state->new, xstrerror()); + fatal("storeAufsDirWriteCleanStart: Failed to write swap log header."); + } state->cur = xstrdup(storeAufsDirSwapLogFile(sd, NULL)); state->cln = xstrdup(storeAufsDirSwapLogFile(sd, ".last-clean")); state->outbuf = xcalloc(CLEAN_BUF_SZ, 1); Index: squid/src/fs/diskd/store_dir_diskd.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/diskd/store_dir_diskd.c,v retrieving revision 1.32.6.8.16.6 retrieving revision 1.32.6.8.16.7 diff -u -r1.32.6.8.16.6 -r1.32.6.8.16.7 --- squid/src/fs/diskd/store_dir_diskd.c 25 Mar 2005 11:54:20 -0000 1.32.6.8.16.6 +++ squid/src/fs/diskd/store_dir_diskd.c 26 Mar 2005 01:46:26 -0000 1.32.6.8.16.7 @@ -545,7 +545,7 @@ rb->log = NULL; } else { debug(47, 1) ("Done scanning %s (%d entries)\n", - rb->sd->path, rb->n_read); + rb->sd->path, rb->counts.scancount); } store_dirs_rebuilding--; storeDiskdDirCloseTmpSwapLog(rb->sd); @@ -1375,9 +1375,9 @@ hd.hdr.op = SWAP_LOG_VERSION; hd.hdr.version = 1; hd.hdr.record_size = sizeof(storeSwapLogData); - if (write(2, &hd, sizeof(hd)) != sizeof(hd)) { + if (write(fd, &hd, sizeof(hd)) != sizeof(hd)) { debug(50, 1) ("%s: %s\n", new_path, xstrerror()); - fatal("storeDirOpenTmpSwapLog: Failed to write swap log."); + fatal("storeDirOpenTmpSwapLog: Failed to write swap log header."); } diskdinfo->swaplog_fd = fd; /* open a read-only stream of the old log */ @@ -1420,6 +1420,10 @@ storeDiskdDirWriteCleanStart(SwapDir * sd) { struct _clean_state *state = xcalloc(1, sizeof(*state)); + union { + storeSwapLogHeader hdr; + storeSwapLogData _data; + } hd; #if HAVE_FCHMOD struct stat sb; #endif @@ -1442,6 +1446,14 @@ } debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n", state->new, state->fd); + memset(&hd, 0, sizeof(hd)); + hd.hdr.op = SWAP_LOG_VERSION; + hd.hdr.version = 1; + hd.hdr.record_size = sizeof(storeSwapLogData); + if (write(state->fd, &hd, sizeof(hd)) != sizeof(hd)) { + debug(50, 1) ("%s: %s\n", state->new, xstrerror()); + fatal("storeDiskdDirWriteCleanStart: Failed to write swap log header."); + } #if HAVE_FCHMOD if (stat(state->cur, &sb) == 0) fchmod(state->fd, sb.st_mode); Index: squid/src/fs/ufs/store_dir_ufs.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/fs/ufs/store_dir_ufs.c,v retrieving revision 1.21.6.10.8.6 retrieving revision 1.21.6.10.8.7 diff -u -r1.21.6.10.8.6 -r1.21.6.10.8.7 --- squid/src/fs/ufs/store_dir_ufs.c 25 Mar 2005 11:54:21 -0000 1.21.6.10.8.6 +++ squid/src/fs/ufs/store_dir_ufs.c 26 Mar 2005 01:46:27 -0000 1.21.6.10.8.7 @@ -382,7 +382,7 @@ rb->log = NULL; } else { debug(47, 1) ("Done scanning %s (%d entries)\n", - rb->sd->path, rb->n_read); + rb->sd->path, rb->counts.scancount); } store_dirs_rebuilding--; storeUfsDirCloseTmpSwapLog(rb->sd); @@ -1161,9 +1161,9 @@ hd.hdr.op = SWAP_LOG_VERSION; hd.hdr.version = 1; hd.hdr.record_size = sizeof(storeSwapLogData); - if (write(2, &hd, sizeof(hd)) != sizeof(hd)) { + if (write(fd, &hd, sizeof(hd)) != sizeof(hd)) { debug(50, 1) ("%s: %s\n", new_path, xstrerror()); - fatal("storeDirOpenTmpSwapLog: Failed to write swap log."); + fatal("storeDirOpenTmpSwapLog: Failed to write swap log header."); } ufsinfo->swaplog_fd = fd; /* open a read-only stream of the old log */ @@ -1209,6 +1209,10 @@ storeUfsDirWriteCleanStart(SwapDir * sd) { struct _clean_state *state = xcalloc(1, sizeof(*state)); + union { + storeSwapLogHeader hdr; + storeSwapLogData _data; + } hd; #if HAVE_FCHMOD struct stat sb; #endif @@ -1225,6 +1229,14 @@ xfree(state); return -1; } + memset(&hd, 0, sizeof(hd)); + hd.hdr.op = SWAP_LOG_VERSION; + hd.hdr.version = 1; + hd.hdr.record_size = sizeof(storeSwapLogData); + if (write(state->fd, &hd, sizeof(hd)) != sizeof(hd)) { + debug(50, 1) ("%s: %s\n", state->new, xstrerror()); + fatal("storeUfsDirWriteCleanStart: Failed to write swap log header."); + } state->cur = xstrdup(storeUfsDirSwapLogFile(sd, NULL)); state->cln = xstrdup(storeUfsDirSwapLogFile(sd, ".last-clean")); state->outbuf = xcalloc(CLEAN_BUF_SZ, 1);