From: hno <> Date: Fri, 9 Aug 2002 02:12:45 +0000 (+0000) Subject: more O_RDONLY/WRONLY test fixes X-Git-Tag: SQUID_3_0_PRE1~860 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5d1a7121c3b4f7fdec111962e0e99f3a115cee0b;p=thirdparty%2Fsquid.git more O_RDONLY/WRONLY test fixes --- diff --git a/src/defines.h b/src/defines.h index 01c34015fe..b65530c5fc 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.106 2002/07/15 09:14:29 hno Exp $ + * $Id: defines.h,v 1.107 2002/08/08 20:12:45 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -313,5 +313,14 @@ #define O_BINARY 0 #endif +/* + * Macro to find file access mode + */ +#ifdef O_ACCMODE +#define FILE_MODE(x) ((x)&O_ACCMODE) +#else +#define FILE_MODE(x) ((x)&(O_RDONLY|O_WRONLY|O_RDWR)) +#endif + #define HTTP_REQBUF_SZ 4096 #endif /* SQUID_DEFINES_H */ diff --git a/src/disk.cc b/src/disk.cc index d874050646..91ff433d76 100644 --- a/src/disk.cc +++ b/src/disk.cc @@ -1,6 +1,6 @@ /* - * $Id: disk.cc,v 1.158 2002/04/13 23:07:50 hno Exp $ + * $Id: disk.cc,v 1.159 2002/08/08 20:12:45 hno Exp $ * * DEBUG: section 6 Disk I/O Routines * AUTHOR: Harvest Derived @@ -60,7 +60,7 @@ int file_open(const char *path, int mode) { int fd; - if (mode & O_WRONLY) + if (FILE_MODE(mode) == O_WRONLY) mode |= O_APPEND; mode |= SQUID_NONBLOCK; errno = 0; diff --git a/src/fs/aufs/store_io_aufs.cc b/src/fs/aufs/store_io_aufs.cc index b49566341b..e1ab3435c1 100644 --- a/src/fs/aufs/store_io_aufs.cc +++ b/src/fs/aufs/store_io_aufs.cc @@ -60,7 +60,7 @@ storeAufsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, ((squidaiostate_t *) (sio->fsstate))->flags.opening = 1; sio->swap_filen = f; sio->swap_dirn = SD->index; - sio->mode = O_RDONLY; + sio->mode = O_RDONLY | O_BINARY; sio->callback = callback; sio->callback_data = cbdataReference(callback_data); sio->e = e; @@ -283,9 +283,9 @@ storeAufsOpenDone(int unused, void *my_data, int fd, int errflag) aiostate->fd = fd; commSetCloseOnExec(fd); fd_open(fd, FD_FILE, storeAufsDirFullPath(INDEXSD(sio->swap_dirn), sio->swap_filen, NULL)); - if (sio->mode & O_WRONLY) + if (FILE_MODE(sio->mode) == O_WRONLY) storeAufsKickWriteQueue(sio); - else if (sio->mode & O_RDONLY) + else if (FILE_MODE(sio->mode) == O_RDONLY) storeAufsKickReadQueue(sio); if (aiostate->flags.close_request) storeAufsIOCallback(sio, errflag); diff --git a/src/fs/coss/store_io_coss.cc b/src/fs/coss/store_io_coss.cc index 61de5104af..cbc94b662a 100644 --- a/src/fs/coss/store_io_coss.cc +++ b/src/fs/coss/store_io_coss.cc @@ -1,6 +1,6 @@ /* - * $Id: store_io_coss.cc,v 1.17 2002/07/28 21:36:31 hno Exp $ + * $Id: store_io_coss.cc,v 1.18 2002/08/08 20:12:45 hno Exp $ * * DEBUG: section 79 Storage Manager COSS Interface * AUTHOR: Eric Stern @@ -144,7 +144,7 @@ storeCossCreate(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, STIOCB * c cstate = memPoolAlloc(coss_state_pool); sio->fsstate = cstate; sio->offset = 0; - sio->mode = O_WRONLY; + sio->mode = O_WRONLY | O_BINARY; /* * If we get handed an object with a size of -1, @@ -198,7 +198,7 @@ storeCossOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, sio->swap_filen = f; sio->swap_dirn = SD->index; sio->offset = 0; - sio->mode = O_RDONLY; + sio->mode = O_RDONLY | O_BINARY; sio->callback = callback; sio->file_callback = file_callback; sio->callback_data = cbdataReference(callback_data); @@ -264,7 +264,7 @@ void storeCossClose(SwapDir * SD, storeIOState * sio) { debug(79, 3) ("storeCossClose: offset %d\n", sio->swap_filen); - if (sio->mode & O_WRONLY) + if (FILE_MODE(sio->mode) == O_WRONLY) storeCossMemBufUnlock(SD, sio); storeCossIOCallback(sio, 0); } diff --git a/src/fs/diskd/store_io_diskd.cc b/src/fs/diskd/store_io_diskd.cc index e197108d05..fe1a48d47b 100644 --- a/src/fs/diskd/store_io_diskd.cc +++ b/src/fs/diskd/store_io_diskd.cc @@ -1,6 +1,6 @@ /* - * $Id: store_io_diskd.cc,v 1.26 2002/07/28 21:36:31 hno Exp $ + * $Id: store_io_diskd.cc,v 1.27 2002/08/08 20:12:46 hno Exp $ * * DEBUG: section 79 Squid-side DISKD I/O functions. * AUTHOR: Duane Wessels @@ -76,7 +76,7 @@ storeDiskdOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, sio->swap_filen = f; sio->swap_dirn = SD->index; - sio->mode = O_RDONLY; + sio->mode = O_RDONLY | O_BINARY; sio->callback = callback; sio->callback_data = cbdataReference(callback_data); sio->e = e; @@ -307,10 +307,10 @@ storeDiskdOpenDone(diomsg * M) debug(79, 3) ("storeDiskdOpenDone: dirno %d, fileno %08x status %d\n", sio->swap_dirn, sio->swap_filen, M->status); if (M->status < 0) { - sio->mode & O_RDONLY ? diskd_stats.open.fail++ : diskd_stats.create.fail++; + FILE_MODE(sio->mode) == O_RDONLY ? diskd_stats.open.fail++ : diskd_stats.create.fail++; storeDiskdIOCallback(sio, DISK_ERROR); } else { - sio->mode & O_RDONLY ? diskd_stats.open.success++ : diskd_stats.create.success++; + FILE_MODE(sio->mode) == O_RDONLY ? diskd_stats.open.success++ : diskd_stats.create.success++; } } diff --git a/src/fs/ufs/store_io_ufs.cc b/src/fs/ufs/store_io_ufs.cc index 242f0e5c45..5d152c6c26 100644 --- a/src/fs/ufs/store_io_ufs.cc +++ b/src/fs/ufs/store_io_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_io_ufs.cc,v 1.10 2002/04/13 23:07:57 hno Exp $ + * $Id: store_io_ufs.cc,v 1.11 2002/08/08 20:12:46 hno Exp $ * * DEBUG: section 79 Storage Manager UFS Interface * AUTHOR: Duane Wessels @@ -68,7 +68,7 @@ storeUfsOpen(SwapDir * SD, StoreEntry * e, STFNCB * file_callback, sio->swap_filen = f; sio->swap_dirn = SD->index; - sio->mode = O_RDONLY; + sio->mode = O_RDONLY | O_BINARY; sio->callback = callback; sio->callback_data = cbdataReference(callback_data); sio->e = e;