ret = -1;
} else {
size_t bufpos;
- for (bufpos = 0; bufpos < buflen; ) {
- ssize_t cnt = read(attrfd, buf + bufpos, buflen - bufpos);
+ for (bufpos = 0; bufpos < sb.st_size; ) {
+ ssize_t cnt = read(attrfd, buf + bufpos, sb.st_size - bufpos);
if (cnt <= 0) {
if (cnt < 0 && errno == EINTR)
continue;
size_t bufpos;
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP;
- if ((attrfd = attropen(path, name, O_CREAT|O_WRONLY|O_NOFOLLOW, mode)) < 0)
+ if ((attrfd = attropen(path, name, O_CREAT|O_TRUNC|O_WRONLY, mode)) < 0)
return -1;
for (bufpos = 0; bufpos < size; ) {
int attrdirfd;
int ret;
- if ((attrdirfd = attropen(path, ".", O_RDWR)) < 0)
+ if ((attrdirfd = attropen(path, ".", O_RDONLY)) < 0)
return -1;
ret = unlinkat(attrdirfd, name, 0);