/*
- * $Id: store_dir_aufs.cc,v 1.44 2002/04/07 11:52:33 hno Exp $
+ * $Id: store_dir_aufs.cc,v 1.45 2002/05/19 16:40:56 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
}
aioinfo->swaplog_fd = fd;
/* open a read-only stream of the old log */
- fp = fopen(swaplog_path, "r");
+ fp = fopen(swaplog_path, "rb");
if (fp == NULL) {
debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
fatal("Failed to open swap log for reading");
}
-#if defined(_SQUID_CYGWIN_)
- setmode(fileno(fp), O_BINARY);
-#endif
memset(&clean_sb, '\0', sizeof(struct stat));
if (stat(clean_path, &clean_sb) < 0)
*clean_flag = 0;
/*
- * $Id: store_dir_coss.cc,v 1.33 2002/04/07 11:52:33 hno Exp $
+ * $Id: store_dir_coss.cc,v 1.34 2002/05/19 16:40:57 hno Exp $
*
* DEBUG: section 81 Store COSS Directory Routines
* AUTHOR: Eric Stern
char *path;
int fd;
path = storeCossDirSwapLogFile(sd, NULL);
- fd = file_open(path, O_WRONLY | O_CREAT);
+ fd = file_open(path, O_WRONLY | O_CREAT | O_BINARY);
if (fd < 0) {
debug(81, 1) ("%s: %s\n", path, xstrerror());
fatal("storeCossDirOpenSwapLog: Failed to open swap log.");
char *new_path = xstrdup(storeCossDirSwapLogFile(sd, ".new"));
int fd;
file_close(cs->swaplog_fd);
-#ifdef _SQUID_OS2_
+#if defined (_SQUID_OS2_) || defined (_SQUID_CYGWIN_)
if (unlink(swaplog_path) < 0) {
debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
fatal("storeCossDirCloseTmpSwapLog: unlink failed");
if (xrename(new_path, swaplog_path) < 0) {
fatal("storeCossDirCloseTmpSwapLog: rename failed");
}
- fd = file_open(swaplog_path, O_WRONLY | O_CREAT);
+ fd = file_open(swaplog_path, O_WRONLY | O_CREAT | O_BINARY);
if (fd < 0) {
debug(50, 1) ("%s: %s\n", swaplog_path, xstrerror());
fatal("storeCossDirCloseTmpSwapLog: Failed to open swap log.");
if (cs->swaplog_fd >= 0)
file_close(cs->swaplog_fd);
/* open a write-only FD for the new log */
- fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC);
+ fd = file_open(new_path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY);
if (fd < 0) {
debug(50, 1) ("%s: %s\n", new_path, xstrerror());
fatal("storeDirOpenTmpSwapLog: Failed to open swap log.");
}
cs->swaplog_fd = fd;
/* open a read-only stream of the old log */
- fp = fopen(swaplog_path, "r");
+ fp = fopen(swaplog_path, "rb");
if (fp == NULL) {
debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
fatal("Failed to open swap log for reading");
struct stat sb;
#endif
state->new = xstrdup(storeCossDirSwapLogFile(sd, ".clean"));
- state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC);
+ state->fd = file_open(state->new, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY);
if (state->fd < 0) {
xfree(state->new);
xfree(state);
static void
storeCossDirWriteCleanDone(SwapDir * sd)
{
+ int fd;
struct _clean_state *state = sd->log.clean.state;
if (NULL == state)
return;
* so we have to close before renaming.
*/
storeCossDirCloseSwapLog(sd);
+ /* save the fd value for a later test */
+ fd = state->fd;
/* rename */
if (state->fd >= 0) {
-#ifdef _SQUID_OS2_
+#if defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_)
file_close(state->fd);
state->fd = -1;
- if (unlink(cur) < 0)
+ if (unlink(state->cur) < 0)
debug(50, 0) ("storeCossDirWriteCleanLogs: unlinkd failed: %s, %s\n",
- xstrerror(), cur);
+ xstrerror(), state->cur);
#endif
xrename(state->new, state->cur);
}
/* touch a timestamp file if we're not still validating */
if (store_dirs_rebuilding)
(void) 0;
- else if (state->fd < 0)
+ else if (fd < 0)
(void) 0;
else
- file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC));
+ file_close(file_open(state->cln, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY));
/* close */
safe_free(state->cur);
safe_free(state->new);
/*
- * $Id: store_dir_ufs.cc,v 1.43 2002/04/07 11:52:34 hno Exp $
+ * $Id: store_dir_ufs.cc,v 1.44 2002/05/19 16:41:01 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
}
ufsinfo->swaplog_fd = fd;
/* open a read-only stream of the old log */
- fp = fopen(swaplog_path, "r");
+ fp = fopen(swaplog_path, "rb");
if (fp == NULL) {
debug(50, 0) ("%s: %s\n", swaplog_path, xstrerror());
fatal("Failed to open swap log for reading");
}
-#if defined(_SQUID_CYGWIN_)
- setmode(fileno(fp), O_BINARY);
-#endif
memset(&clean_sb, '\0', sizeof(struct stat));
if (stat(clean_path, &clean_sb) < 0)
*clean_flag = 0;