25#if _SQUID_WINDOWS_ || _SQUID_OS2_
27diskWriteIsComplete(
int fd)
29 return fd_table[fd].disk.write_q ? 0 : 1;
54 fd = open(path, mode, 0644);
60 debugs(50, 3,
"error opening file " << path <<
": " <<
xstrerr(xerrno));
80 if ((read_callback =
F->read_handler)) {
81 F->read_handler =
nullptr;
82 read_callback(-1,
F->read_data);
85 if (
F->flags.write_daemon) {
86#if _SQUID_WINDOWS_ || _SQUID_OS2_
91 while (!diskWriteIsComplete(fd))
94 F->flags.close_request =
true;
95 debugs(6, 2,
"file_close: FD " << fd <<
", delaying close");
105 assert(
F->write_handler ==
nullptr);
109 debugs(6,
F->flags.close_request ? 2 : 5,
"file_close: FD " << fd <<
" really closing");
139 len += q->len - q->buf_offset;
153 while (fdd->
write_q !=
nullptr) {
188 debugs(6, 3,
"diskHandleWrite: FD " << fd);
190 F->flags.write_daemon =
false;
196 debugs(6, 3,
"diskHandleWrite: FD " << fd <<
" writing " <<
214 const auto xerrno = errno;
216 debugs(6, 3,
"diskHandleWrite: FD " << fd <<
" len = " << len);
238 fatal(
"Write failure -- check your disk space and cache.log");
272 len <<
" FD " << fd <<
")");
297 F->flags.write_daemon =
true;
308 callback(fd, status, len,
cbdata);
328 void const *ptr_to_buf,
341 wq->
buf = (
char *)ptr_to_buf;
347 if (!
F->disk.wrt_handle_data) {
352 assert(
F->disk.wrt_handle_data == handle_data &&
F->disk.wrt_handle ==
handle);
356 if (
F->disk.write_q ==
nullptr) {
358 F->disk.write_q =
F->disk.write_q_tail = wq;
360 F->disk.write_q_tail->next = wq;
361 F->disk.write_q_tail = wq;
364 if (!
F->flags.write_daemon) {
399#if WRITES_MAINTAIN_DISK_OFFSET
400 if (
F->disk.offset != ctrl_dat->
offset) {
404 debugs(6, 3,
"diskHandleRead: FD " << fd <<
" seeking to offset " << ctrl_dat->
offset);
406 if (lseek(fd, ctrl_dat->
offset, SEEK_SET) == -1) {
413 F->disk.offset = ctrl_dat->
offset;
421 F->disk.offset += len;
436 }
else if (len == 0) {
459 ctrl_dat->
offset = offset;
473 if (unlink(s) < 0 && !quiet) {
482 debugs(21, 2,
"renaming " << from <<
" to " << to);
489#if _SQUID_OS2_ || _SQUID_WINDOWS_
497 debugs(21, (xerrno == ENOENT ? 2 :
DBG_IMPORTANT),
"ERROR: Cannot rename " << from <<
" to " << to <<
": " <<
xstrerr(xerrno));
523#define fsbtoblk(num, fsbs, bs) \
524 (((fsbs) != 0 && (fsbs) < (bs)) ? \
525 (num) / ((bs) / (fsbs)) : (num) * ((fsbs) / (bs)))
527fsStats(
const char *path,
int *totl_kb,
int *free_kb,
int *totl_in,
int *free_in)
int cbdataReferenceValid(const void *p)
#define cbdataReferenceDone(var)
#define cbdataReference(var)
#define cbdataReferenceValidDone(var, ptr)
const char * rawContent() const
size_type length() const
Returns the number of bytes stored in SBuf.
struct StatCounters::@130 syscalls
struct StatCounters::@130::@134 disk
void fd_open(const int fd, unsigned int, const char *description)
void fd_close(const int fd)
void commSetCloseOnExec(int fd)
int ignoreErrno(int ierrno)
#define debugs(SECTION, LEVEL, CONTENT)
#define COMM_SELECT_WRITE
#define DISK_NO_SPACE_LEFT
static int do_close(diomsg *r, int)
void fatal(const char *message)
void fd_bytes(int fd, int len, unsigned int type)
int FD_READ_METHOD(int fd, char *buf, int len)
int FD_WRITE_METHOD(int fd, const char *buf, int len)
int file_open(const char *path, int mode)
#define fsbtoblk(num, fsbs, bs)
static void diskCombineWrites(_fde_disk *fdd)
bool FileRename(const SBuf &from, const SBuf &to)
void safeunlink(const char *s, int quiet)
void file_read(int fd, char *buf, int req_len, off_t offset, DRCB *handler, void *client_data)
int fsBlockSize(const char *path, int *blksize)
static PF diskHandleWrite
static void cxx_xfree(void *ptr)
void file_write_mbuf(int fd, off_t off, MemBuf mb, DWCB *handler, void *handler_data)
int fsStats(const char *path, int *totl_kb, int *free_kb, int *totl_in, int *free_in)
void file_write(int fd, off_t file_offset, void const *ptr_to_buf, int len, DWCB *handle, void *handle_data, FREE *free_func)
static uint32 F(uint32 X, uint32 Y, uint32 Z)
void memFree(void *, int type)
Free a element allocated by memAllocate()
void * memAllocate(mem_type)
Allocate one element from the typed pool.
void SetSelect(int, unsigned int, PF *, void *, time_t)
Mark an FD to be watched for its IO status.
static void handler(int signo)
int xstatvfs(const char *path, struct statvfs *sfs)
void DRCB(int, const char *buf, int size, int errflag, void *data)
void DWCB(int, int, size_t, void *)
const char * xstrerr(int error)