* \retval 0 on success
* \retval -ve on failure
*/
-int llapi_root_path_open(char *device, int *rootfd)
+int llapi_root_path_open(const char *device, int *rootfd)
{
int tmp_fd, rc;
{
int rootfd, rc;
- rc = llapi_root_path_open((char *)path, &rootfd);
+ rc = llapi_root_path_open(path, &rootfd);
if (rc < 0) {
fprintf(stderr,
"lfs rmfid: error opening device/fsname '%s': %s\n",
}
rc = llapi_rmfid_at(rootfd, fa);
+ close(rootfd);
if (rc < 0) {
fprintf(stderr, "lfs rmfid: cannot remove FIDs: %s\n",
strerror(-rc));
int rc = 0;
dirpath = strdup(dname);
- namepath = strdup(dname);
- if (!dirpath || !namepath)
+ if (!dirpath)
return -ENOMEM;
+ namepath = strdup(dname);
+ if (!namepath) {
+ rc = -ENOMEM;
+ goto out_dirpath;
+ }
+
filename = basename(namepath);
dir = dirname(dirpath);
"error on ioctl %#lx for '%s' (%d)",
(long)LL_IOC_LMV_SETSTRIPE, filename, fd);
out:
- free(dirpath);
+ close(fd);
free(namepath);
- if (fd != -1)
- close(fd);
+out_dirpath:
+ free(dirpath);
return rc;
#else
return -EOPNOTSUPP;