Lines Matching refs:fd
38 int fd;
52 int fd;
65 if (fcntl(apl->fd, F_SETLKW, &lock) >= 0)
67 if (lseek(apl->fd, apl->size, SEEK_SET) != apl->size)
69 else if (read(apl->fd, &references, sizeof(references)) != sizeof(references))
74 if (lseek(apl->fd, apl->size, SEEK_SET) != apl->size)
76 else if (write(apl->fd, &references, sizeof(references)) != sizeof(references))
80 fcntl(apl->fd, F_SETLK, &lock);
84 close(apl->fd);
88 fd = -1;
114 if (!(path = pathtemp(buf, sizeof(buf), NiL, "aso", &fd)))
120 if (fd >= 0 || (fd = open(path, O_RDWR|O_cloexec)) < 0 && (fd = open(path, O_CREAT|O_RDWR|O_cloexec, perm)) >= 0)
122 if (lseek(fd, size, SEEK_SET) != size)
125 if (write(fd, &references, sizeof(references)) != sizeof(references))
130 if ((size = lseek(fd, 0, SEEK_END)) <= sizeof(references))
137 if (fcntl(fd, F_SETLKW, &lock) < 0)
139 if (lseek(fd, size, SEEK_SET) != size)
141 if (read(fd, &references, sizeof(references)) != sizeof(references))
144 if (lseek(fd, size, SEEK_SET) != size)
146 if (write(fd, &references, sizeof(references)) != sizeof(references))
149 fcntl(fd, F_SETLK, &lock);
151 apl->fd = fd;
158 if (fd >= 0)
159 close(fd);
183 return fcntl(apl->fd, F_SETLKW, &lock) < 0 ? -1 : k;