Lines Matching refs:fd
83 int fd; in create_file() local
89 fd = open(filename, O_RDWR | O_CREAT, mode); in create_file()
90 if (fd < 0) in create_file()
91 return fd; in create_file()
93 close(fd); in create_file()
141 static inline int write_key_value(int fd, const char *key, const char *value) in write_key_value() argument
155 if (write(fd, str, size) < 0) in write_key_value()
191 int fd, len, err = 0; in write_key() local
193 fd = open(pathname, O_RDWR); in write_key()
194 if (fd < 0) in write_key()
197 if (flock(fd, LOCK_EX) < 0) { in write_key()
202 if (fstat(fd, &st) < 0) { in write_key()
211 lseek(fd, size, SEEK_SET); in write_key()
212 err = write_key_value(fd, key, value); in write_key()
218 MAP_PRIVATE | MAP_LOCKED, fd, 0); in write_key()
229 lseek(fd, size, SEEK_SET); in write_key()
230 err = write_key_value(fd, key, value); in write_key()
253 if (ftruncate(fd, base) < 0) { in write_key()
257 lseek(fd, base, SEEK_SET); in write_key()
259 err = write_key_value(fd, key, value); in write_key()
278 if (ftruncate(fd, base) < 0) { in write_key()
283 lseek(fd, base, SEEK_SET); in write_key()
285 err = write_key_value(fd, key, value); in write_key()
287 if (write(fd, str, len) < 0) in write_key()
298 flock(fd, LOCK_UN); in write_key()
301 fdatasync(fd); in write_key()
303 close(fd); in write_key()
314 int fd, err = 0; in read_key() local
316 fd = open(pathname, O_RDONLY); in read_key()
317 if (fd < 0) in read_key()
320 if (flock(fd, LOCK_SH) < 0) { in read_key()
325 if (fstat(fd, &st) < 0) { in read_key()
332 map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); in read_key()
364 flock(fd, LOCK_UN); in read_key()
367 close(fd); in read_key()
408 int fd, err = 0; in textfile_foreach() local
410 fd = open(pathname, O_RDONLY); in textfile_foreach()
411 if (fd < 0) in textfile_foreach()
414 if (flock(fd, LOCK_SH) < 0) { in textfile_foreach()
419 if (fstat(fd, &st) < 0) { in textfile_foreach()
426 map = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); in textfile_foreach()
490 flock(fd, LOCK_UN); in textfile_foreach()
493 close(fd); in textfile_foreach()