Signed-off-by: Karel Zak <kzak@redhat.com>
struct stat st;
struct libmnt_iter itr;
struct libmnt_fs *fs;
- int fd;
mnt_reset_iter(&itr, MNT_ITER_FORWARD);
while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
goto leave;
}
- fd = fileno(f);
rc = fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) ? -errno : 0;
if (!rc && stat(upd->filename, &st) == 0)
rc = fchown(fd, st.st_uid, st.st_gid) ? -errno : 0;
fclose(f);
+ f = NULL;
rc = rename(uq, upd->filename) ? -errno : 0;
} else {
rc = -errno;
}
leave:
+ if (f)
+ fclose(f);
+
unlink(uq); /* be paranoid */
free(uq);
return rc;