12 #if (NGX_HAVE_FILE_AIO)
25 "read: %d, %p, %uz, %O", file->
fd, buf, size, offset);
29 n = pread(file->
fd, buf, size, offset);
33 "pread() \"%s\" failed", file->
name.
data);
40 if (lseek(file->
fd, offset, SEEK_SET) == -1) {
42 "lseek() \"%s\" failed", file->
name.
data);
49 n = read(file->
fd, buf, size);
53 "read() \"%s\" failed", file->
name.
data);
73 "write: %d, %p, %uz, %O", file->
fd, buf, size, offset);
80 n = pwrite(file->
fd, buf + written, size, offset);
84 "pwrite() \"%s\" failed", file->
name.
data);
91 if ((
size_t) n == size) {
102 if (lseek(file->
fd, offset, SEEK_SET) == -1) {
104 "lseek() \"%s\" failed", file->
name.
data);
112 n = write(file->
fd, buf + written, size);
116 "write() \"%s\" failed", file->
name.
data);
123 if ((
size_t) n == size) {
138 fd = open((
const char *) name, O_CREAT|O_EXCL|O_RDWR,
139 access ? access : 0600);
141 if (fd != -1 && !persistent) {
142 (void) unlink((
const char *) name);
163 if (cl->
next == NULL) {
172 vec.
size =
sizeof(
struct iovec);
186 if (prev == cl->
buf->
pos) {
195 iov->iov_base = (
void *) cl->
buf->
pos;
206 if (vec.
nelts == 1) {
210 iov[0].iov_len, offset);
220 if (lseek(file->
fd, offset, SEEK_SET) == -1) {
222 "lseek() \"%s\" failed", file->
name.
data);
233 "writev() \"%s\" failed", file->
name.
data);
237 if ((
size_t) n != size) {
239 "writev() \"%s\" has written only %z of %uz",
245 "writev: %d, %z", file->
fd, n);
261 struct timeval tv[2];
268 if (utimes((
char *) name, tv) != -1) {
287 if (ftruncate(fm->
fd, fm->
size) == -1) {
289 "ftruncate() \"%s\" failed", fm->
name);
293 fm->
addr = mmap(NULL, fm->
size, PROT_READ|PROT_WRITE, MAP_SHARED,
295 if (fm->
addr != MAP_FAILED) {
300 "mmap(%uz) \"%s\" failed", fm->
size, fm->
name);
316 if (munmap(fm->
addr, fm->
size) == -1) {
318 "munmap(%uz) \"%s\" failed", fm->
size, fm->
name);
331 dir->
dir = opendir((
const char *) name->
data);
333 if (dir->
dir == NULL) {
346 dir->
de = readdir(dir->
dir);
349 #if (NGX_HAVE_D_TYPE)
350 dir->
type = dir->
de->d_type;
374 if (n == GLOB_NOMATCH && gl->
test) {
390 count = (size_t) gl->
pglob.gl_pathc;
392 count = (
size_t) gl->
pglob.gl_matchc;
398 name->
data = (u_char *) gl->
pglob.gl_pathv[gl->
n];
411 globfree(&gl->
pglob);
422 fl.l_whence = SEEK_SET;
424 if (fcntl(fd, F_SETLK, &fl) == -1) {
439 fl.l_whence = SEEK_SET;
441 if (fcntl(fd, F_SETLKW, &fl) == -1) {
456 fl.l_whence = SEEK_SET;
458 if (fcntl(fd, F_SETLK, &fl) == -1) {
466 #if (NGX_HAVE_POSIX_FADVISE) && !(NGX_HAVE_F_READAHEAD)
473 err = posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
486 #if (NGX_HAVE_O_DIRECT)
493 flags = fcntl(fd, F_GETFL);
499 return fcntl(fd, F_SETFL, flags | O_DIRECT);
508 flags = fcntl(fd, F_GETFL);
514 return fcntl(fd, F_SETFL, flags & ~O_DIRECT);
520 #if (NGX_HAVE_STATFS)
527 if (statfs((
char *) name, &fs) == -1) {
531 if ((fs.f_bsize % 512) != 0) {
535 return (
size_t) fs.f_bsize;
538 #elif (NGX_HAVE_STATVFS)
545 if (statvfs((
char *) name, &fs) == -1) {
549 if ((fs.f_frsize % 512) != 0) {
553 return (
size_t) fs.f_frsize;