]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Robert Collins' Cygwin file mode support and ufs writecleanswap bugfix.
authorwessels <>
Thu, 4 Jan 2001 10:42:34 +0000 (10:42 +0000)
committerwessels <>
Thu, 4 Jan 2001 10:42:34 +0000 (10:42 +0000)
Without it users on cygwin with text mode mounts will die badly,
and all cygwin users will not ever see a (CLEAN) status on their
cache_dir's. Why I was getting clean status when I first looked
into this may be due to some of the 'emulation' work done on cygwin
to make UN*X assumptions (ie unlinking open files) work somewhat.

18 files changed:
src/acl.cc
src/cache_cf.cc
src/cache_diff.cc
src/cf_gen.cc
src/client.cc
src/debug.cc
src/defines.h
src/dns_internal.cc
src/errorpage.cc
src/fs/ufs/store_dir_ufs.cc
src/fs/ufs/store_io_ufs.cc
src/logfile.cc
src/main.cc
src/mime.cc
src/net_db.cc
src/send-announce.cc
src/squid.h
src/tools.cc

index 1acbfa28488def98ca6ec91288b7d70c21a9477a..cc7083e8cf195cd92dc2e7fa9e25e28c8935eba2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: acl.cc,v 1.228 2001/01/02 00:09:55 wessels Exp $
+ * $Id: acl.cc,v 1.229 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -120,6 +120,9 @@ strtokFile(void)
                debug(28, 0) ("strtokFile: %s not found\n", fn);
                return (NULL);
            }
+#if defined(_SQUID_CYGWIN_)
+           setmode(fileno(aclFile), O_TEXT);
+#endif
            aclFromFile = 1;
        } else {
            return t;
index 151790cbb86388a6ef28cbd35fc5a39a7da70e2d..b898d1c3ba95c97c14f9269d5d6508155fa54140 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.362 2001/01/02 01:41:30 wessels Exp $
+ * $Id: cache_cf.cc,v 1.363 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -218,6 +218,9 @@ parseConfigFile(const char *file_name)
     if ((fp = fopen(file_name, "r")) == NULL)
        fatalf("Unable to open configuration file: %s: %s",
            file_name, xstrerror());
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(fp), O_TEXT);
+#endif
     cfg_filename = file_name;
     if ((token = strrchr(cfg_filename, '/')))
        cfg_filename = token + 1;
index 9379a62d474da5548f48522ddfd5cec6c3738957..b447511e26730be668b65c5fc7b30db288058af8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_diff.cc,v 1.13 2000/10/31 23:48:13 wessels Exp $
+ * $Id: cache_diff.cc,v 1.14 2001/01/04 03:42:34 wessels Exp $
  *
  * AUTHOR: Alex Rousskov
  *
@@ -137,6 +137,9 @@ cacheIndexAddLog(CacheIndex * idx, const char *fname)
        fprintf(stderr, "cannot open %s: %s\n", fname, strerror(errno));
        return 0;
     }
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(file), O_BINARY);
+#endif
     scanned_count = cacheIndexScan(idx, fname, file);
 
     fclose(file);
index 1e6441fe819900affe7cb3050f71785c04dadbab..6353701ad78d8482664cfd56d7dc9336bc119ad4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cf_gen.cc,v 1.37 2000/11/25 16:02:14 adrian Exp $
+ * $Id: cf_gen.cc,v 1.38 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: none          Generate squid.conf and cf_parser.c
  * AUTHOR: Max Okumoto
 #if HAVE_ASSERT_H
 #include <assert.h>
 #endif
+#if defined(_SQUID_CYGWIN_)
+#include <io.h>
+#endif
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
 
 #include "util.h"
 
@@ -145,6 +151,9 @@ main(int argc, char *argv[])
        perror(input_filename);
        exit(1);
     }
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(fp), O_TEXT);
+#endif
     state = sSTART;
     while (feof(fp) == 0 && state != sEXIT) {
        char buff[MAX_LINE];
@@ -318,6 +327,9 @@ main(int argc, char *argv[])
        perror(output_filename);
        exit(1);
     }
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(fp), O_TEXT);
+#endif
     fprintf(fp,
        "/*\n"
        " * Generated automatically from %s by %s\n"
@@ -340,6 +352,9 @@ main(int argc, char *argv[])
        perror(conf_filename);
        exit(1);
     }
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(fp), O_TEXT);
+#endif
     gen_conf(entries, fp);
     fclose(fp);
 
index 7077fc9e6237c9efed6ae482b2c55a0dcf35f1a2..4c5bedef395b1c96c943dfc3d9ccf030ee3c75bd 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client.cc,v 1.89 2000/08/15 02:37:14 wessels Exp $
+ * $Id: client.cc,v 1.90 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 0     WWW Client
  * AUTHOR: Harvest Derived
@@ -203,6 +203,9 @@ main(int argc, char *argv[])
                xstrerror());
            exit(-1);
        }
+#if defined(_SQUID_CYGWIN_)
+       setmode(put_fd, O_BINARY);
+#endif
        fstat(put_fd, &sb);
     }
     snprintf(msg, BUFSIZ, "%s %s HTTP/1.0\r\n", method, url);
index 18269c00347180d188d5d7266b936e1e1b10c9b7..3267b988c2b3495c22f5234dabeb9f84e3fcac9d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: debug.cc,v 1.78 2000/03/06 16:23:30 wessels Exp $
+ * $Id: debug.cc,v 1.79 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 0     Debug Routines
  * AUTHOR: Harvest Derived
@@ -157,6 +157,9 @@ debugOpenLog(const char *logfile)
        fflush(stderr);
        debug_log = stderr;
     }
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(debug_log), O_TEXT);
+#endif
 }
 
 void
index 09ea28b2c251d593e182b8761c3ab06720d3b298..f4ba2167832cb0e8b4c3217dbe53f0cad103c197 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: defines.h,v 1.83 2000/10/17 08:06:03 adrian Exp $
+ * $Id: defines.h,v 1.84 2001/01/04 03:42:34 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
 #ifndef _PATH_DEVNULL
 #define _PATH_DEVNULL "/dev/null"
 #endif
+
+#ifndef O_TEXT
+#define O_TEXT 0
+#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
index 1496bdb099e896b627d66abf377d5e5f80fa62de..bf8b0d6e9e9af4db541a299a9917df12f23ae433 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.cc,v 1.34 2000/11/03 17:03:54 wessels Exp $
+ * $Id: dns_internal.cc,v 1.35 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c
  * AUTHOR: Duane Wessels
@@ -148,6 +148,9 @@ idnsParseResolvConf(void)
        debug(78, 1) ("%s: %s\n", _PATH_RESOLV_CONF, xstrerror());
        return;
     }
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(fp), O_TEXT);
+#endif
     while (fgets(buf, 512, fp)) {
        t = strtok(buf, w_space);
        if (NULL == t)
index 763ef0c92a56e441f912f8d04a28e50a331e0c88..ffd3e4be463c4cb5c35cf0d9f08f40f11c9316a7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.158 2000/12/08 23:58:08 wessels Exp $
+ * $Id: errorpage.cc,v 1.159 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
@@ -171,7 +171,7 @@ errorTryLoadText(const char *page_name, const char *dir)
     char *text;
 
     snprintf(path, sizeof(path), "%s/%s", dir, page_name);
-    fd = file_open(path, O_RDONLY);
+    fd = file_open(path, O_RDONLY | O_TEXT);
     if (fd < 0 || fstat(fd, &sb) < 0) {
        debug(4, 0) ("errorTryLoadText: '%s': %s\n", path, xstrerror());
        if (fd >= 0)
index 04b2ecf62e5b28a54e272f841a38b1da1f18ad8e..0db450a9f7c039cd10ac229cff8014631d3977a3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.21 2001/01/02 01:41:35 wessels Exp $
+ * $Id: store_dir_ufs.cc,v 1.22 2001/01/04 03:42:38 wessels Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -322,7 +322,7 @@ storeUfsDirOpenSwapLog(SwapDir * sd)
     char *path;
     int fd;
     path = storeUfsDirSwapLogFile(sd, NULL);
-    fd = file_open(path, O_WRONLY | O_CREAT);
+    fd = file_open(path, O_WRONLY | O_CREAT | O_BINARY);
     if (fd < 0) {
        debug(50, 1) ("%s: %s\n", path, xstrerror());
        fatal("storeUfsDirOpenSwapLog: Failed to open swap log.");
@@ -756,7 +756,7 @@ storeUfsDirGetNextFile(RebuildState * rb, int *sfileno, int *size)
            snprintf(rb->fullfilename, SQUID_MAXPATHLEN, "%s/%s",
                rb->fullpath, rb->entry->d_name);
            debug(20, 3) ("storeUfsDirGetNextFile: Opening %s\n", rb->fullfilename);
-           fd = file_open(rb->fullfilename, O_RDONLY);
+           fd = file_open(rb->fullfilename, O_RDONLY | O_BINARY);
            if (fd < 0)
                debug(50, 1) ("storeUfsDirGetNextFile: %s: %s\n", rb->fullfilename, xstrerror());
            else
@@ -862,7 +862,7 @@ storeUfsDirCloseTmpSwapLog(SwapDir * sd)
     char *new_path = xstrdup(storeUfsDirSwapLogFile(sd, ".new"));
     int fd;
     file_close(ufsinfo->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("storeUfsDirCloseTmpSwapLog: unlink failed");
@@ -871,7 +871,7 @@ storeUfsDirCloseTmpSwapLog(SwapDir * sd)
     if (xrename(new_path, swaplog_path) < 0) {
        fatal("storeUfsDirCloseTmpSwapLog: 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("storeUfsDirCloseTmpSwapLog: Failed to open swap log.");
@@ -905,7 +905,7 @@ storeUfsDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag)
     if (ufsinfo->swaplog_fd >= 0)
        file_close(ufsinfo->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.");
@@ -917,6 +917,9 @@ storeUfsDirOpenTmpSwapLog(SwapDir * sd, int *clean_flag, int *zero_flag)
        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;
@@ -955,7 +958,7 @@ storeUfsDirWriteCleanStart(SwapDir * sd)
     sd->log.clean.write = NULL;
     sd->log.clean.state = NULL;
     state->new = xstrdup(storeUfsDirSwapLogFile(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);
@@ -966,7 +969,9 @@ storeUfsDirWriteCleanStart(SwapDir * sd)
     state->outbuf = xcalloc(CLEAN_BUF_SZ, 1);
     state->outbuf_offset = 0;
     state->walker = sd->repl->WalkInit(sd->repl);
+#if !(defined(_SQUID_OS2_) || defined (_SQUID_CYGWIN_))
     unlink(state->new);
+#endif
     unlink(state->cln);
     debug(20, 3) ("storeDirWriteCleanLogs: opened %s, FD %d\n",
        state->new, state->fd);
@@ -1034,6 +1039,7 @@ storeUfsDirWriteCleanEntry(SwapDir * sd, const StoreEntry * e)
 static void
 storeUfsDirWriteCleanDone(SwapDir * sd)
 {
+    int fd;
     struct _clean_state *state = sd->log.clean.state;
     if (NULL == state)
        return;
@@ -1055,24 +1061,26 @@ storeUfsDirWriteCleanDone(SwapDir * sd)
      * so we have to close before renaming.
      */
     storeUfsDirCloseSwapLog(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) ("storeDirWriteCleanLogs: 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);
index 6364396da51729f6e540b1c2618128f15462a55c..fed25de8eea3d8386c37dfb6133e6fec06f02da2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_io_ufs.cc,v 1.3 2000/06/26 20:17:13 adrian Exp $
+ * $Id: store_io_ufs.cc,v 1.4 2001/01/04 03:42:38 wessels Exp $
  *
  * DEBUG: section 79    Storage Manager UFS Interface
  * AUTHOR: Duane Wessels
@@ -54,7 +54,7 @@ storeUfsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback,
     struct stat sb;
     int fd;
     debug(79, 3) ("storeUfsOpen: fileno %08X\n", f);
-    fd = file_open(path, O_RDONLY);
+    fd = file_open(path, O_RDONLY | O_BINARY);
     if (fd < 0) {
        debug(79, 3) ("storeUfsOpen: got failure (%d)\n", errno);
        return NULL;
@@ -88,7 +88,7 @@ storeUfsCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * ca
 {
     storeIOState *sio;
     int fd;
-    int mode = (O_WRONLY | O_CREAT | O_TRUNC);
+    int mode = (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY);
     char *path;
     ufsinfo_t *ufsinfo = (ufsinfo_t *) SD->fsdata;
     sfileno filn;
index 707771d1315db9f59e762dd98deb5c09d191ad8a..85edf7231f5466f893b8d738fec1690dc962f847 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: logfile.cc,v 1.6 2000/10/10 18:15:30 wessels Exp $
+ * $Id: logfile.cc,v 1.7 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 50    Log file handling
  * AUTHOR: Duane Wessels
@@ -41,7 +41,7 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
 {
     int fd;
     Logfile *lf;
-    fd = file_open(path, O_WRONLY | O_CREAT);
+    fd = file_open(path, O_WRONLY | O_CREAT | O_TEXT);
     if (DISK_ERROR == fd) {
        if (ENOENT == errno && fatal_flag) {
            fatalf("Cannot open '%s' because\n"
@@ -108,7 +108,7 @@ logfileRotate(Logfile * lf)
        xrename(lf->path, to);
     }
     /* Reopen the log.  It may have been renamed "manually" */
-    lf->fd = file_open(lf->path, O_WRONLY | O_CREAT);
+    lf->fd = file_open(lf->path, O_WRONLY | O_CREAT | O_TEXT);
     if (DISK_ERROR == lf->fd && lf->flags.fatal) {
        debug(50, 1) ("logfileRotate: %s: %s\n", lf->path, xstrerror());
        fatalf("Cannot open %s: %s", lf->path, xstrerror());
index ccf195b6601227fa310b99d02c8ceecc992cde41..8ff720c773cc7660bd4eb08fba81cdb2f74a6976 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.326 2001/01/01 16:24:39 hno Exp $
+ * $Id: main.cc,v 1.327 2001/01/04 03:42:34 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -845,7 +845,7 @@ watch_child(char *argv[])
        syslog(LOG_ALERT, "setsid failed: %s", xstrerror());
     closelog();
 #ifdef TIOCNOTTY
-    if ((i = open("/dev/tty", O_RDWR)) >= 0) {
+    if ((i = open("/dev/tty", O_RDWR | O_TEXT)) >= 0) {
        ioctl(i, TIOCNOTTY, NULL);
        close(i);
     }
@@ -858,7 +858,7 @@ watch_child(char *argv[])
      * 1.1.3.  execvp had a bit overflow error in a loop..
      */
     /* Connect stdio to /dev/null in daemon mode */
-    nullfd = open("/dev/null", O_RDWR);
+    nullfd = open("/dev/null", O_RDWR | O_TEXT);
     dup2(nullfd, 0);
     if (opt_debug_stderr < 0) {
        dup2(nullfd, 1);
index 2a6840c4b486da81b895109d3da2123e0075064c..c50387569bfd9fe74fab4d420e773b4ab5f1b003 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mime.cc,v 1.97 2001/01/01 16:24:39 hno Exp $
+ * $Id: mime.cc,v 1.98 2001/01/04 03:42:35 wessels Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -297,6 +297,9 @@ mimeInit(char *filename)
        debug(50, 1) ("mimeInit: %s: %s\n", filename, xstrerror());
        return;
     }
+#if defined (_SQUID_CYGWIN_)
+    setmode(fileno(fp), O_TEXT);
+#endif
     mimeFreeMemory();
     while (fgets(buf, BUFSIZ, fp)) {
        if ((t = strchr(buf, '#')))
@@ -406,7 +409,7 @@ mimeLoadIconFile(const char *icon)
     if (storeGetPublic(url, METHOD_GET))
        return;
     snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon);
-    fd = file_open(path, O_RDONLY);
+    fd = file_open(path, O_RDONLY | O_BINARY);
     if (fd < 0) {
        debug(25, 0) ("mimeLoadIconFile: %s: %s\n", path, xstrerror());
        return;
index c65d80b792a124c6ebef8b5d8cda82c99b28d7d7..13d5929ee5bac4ded40014b115b7535b39b97683 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.153 2000/11/13 23:30:26 wessels Exp $
+ * $Id: net_db.cc,v 1.154 2001/01/04 03:42:35 wessels Exp $
  *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -435,7 +435,7 @@ netdbReloadState(void)
      * Solaris bugs, its a bad idea.  fopen can fail if more than
      * 256 FDs are open.
      */
-    fd = file_open(path, O_RDONLY);
+    fd = file_open(path, O_RDONLY | O_TEXT);
     if (fd < 0)
        return;
     if (fstat(fd, &sb) < 0)
index 131738668178d89e991a475224198f88ff381cbd..e67ef7f04a785093e4cb5be5f94eb81feff3106d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: send-announce.cc,v 1.58 2000/03/06 16:23:34 wessels Exp $
+ * $Id: send-announce.cc,v 1.59 2001/01/04 03:42:35 wessels Exp $
  *
  * DEBUG: section 27    Cache Announcer
  * AUTHOR: Duane Wessels
@@ -88,7 +88,7 @@ send_announce(const ipcache_addrs * ia, void *junk)
     strcat(sndbuf, tbuf);
     l = strlen(sndbuf);
     if ((file = Config.Announce.file) != NULL) {
-       fd = file_open(file, O_RDONLY);
+       fd = file_open(file, O_RDONLY | O_TEXT);
        if (fd > -1 && (n = read(fd, sndbuf + l, BUFSIZ - l - 1)) > 0) {
            fd_bytes(fd, n, FD_READ);
            l += n;
index 46b75dabb9b412e080ca71c73ee44b9176f79c89..761500e31e6ac05d86732f150a8f8deb8b962463 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: squid.h,v 1.203 2000/08/07 23:01:18 wessels Exp $
+ * $Id: squid.h,v 1.204 2001/01/04 03:42:35 wessels Exp $
  *
  * AUTHOR: Duane Wessels
  *
 #if HAVE_LIMITS_H
 #include <limits.h>
 #endif
+#if defined(_SQUID_CYGWIN_)
+#include <io.h>
+#endif
 
 #if HAVE_DIRENT_H
 #include <dirent.h>
index e232ac30636b2e40a9f225ccc0aea1ac10071845..f08689b333531ef380568f3b565d76ea810efcb2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.201 2000/12/31 23:53:08 wessels Exp $
+ * $Id: tools.cc,v 1.202 2001/01/04 03:42:35 wessels Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -578,7 +578,7 @@ writePidFile(void)
        return;
     enter_suid();
     old_umask = umask(022);
-    fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC);
+    fd = file_open(f, O_WRONLY | O_CREAT | O_TRUNC | O_TEXT);
     umask(old_umask);
     leave_suid();
     if (fd < 0) {
@@ -955,6 +955,9 @@ parseEtcHosts(void)
            Config.etcHostsPath, xstrerror());
        return;
     }
+#if defined(_SQUID_CYGWIN_)
+    setmode(fileno(fp), O_TEXT);
+#endif
     while (fgets(buf, 1024, fp)) {     /* for each line */
        wordlist *hosts = NULL;
        if (buf[0] == '#')      /* MS-windows likes to add comments */