goto errout;
uuid_unparse(fs->super->s_uuid, uuid);
sprintf(fn, "%s/%s-icount-XXXXXX", tdb_dir, uuid);
+ icount->tdb_fn = fn;
fd = mkstemp(fn);
- if (fd < 0)
- return fd;
-
+ if (fd < 0) {
+ retval = errno;
+ goto errout;
+ }
/*
* This is an overestimate of the size that we will need; the
* ideal value is the number of used inodes with a count
*/
num_inodes = fs->super->s_inodes_count - fs->super->s_free_inodes_count;
- icount->tdb_fn = fn;
icount->tdb = tdb_open(fn, num_inodes, TDB_NOLOCK | TDB_NOSYNC,
O_RDWR | O_CREAT | O_TRUNC, 0600);
- if (icount->tdb) {
- close(fd);
- *ret = icount;
- return 0;
- }
-
- retval = errno;
close(fd);
-
+ if (icount->tdb == NULL) {
+ retval = errno;
+ goto errout;
+ }
+ *ret = icount;
+ return 0;
errout:
ext2fs_free_icount(icount);
return(retval);