]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - libfrog/fsgeom.c
libfrog: introduce xfs_fd to wrap an fd to a file on an xfs filesystem
[thirdparty/xfsprogs-dev.git] / libfrog / fsgeom.c
index 20a92ec1ad9a938f54cf8f7632c7b9610b8acf50..9513faf57e9f02ebdb371ed3e4b00c4b683161a7 100644 (file)
@@ -92,3 +92,35 @@ xfrog_geometry(
 
        return errno;
 }
+
+/*
+ * Prepare xfs_fd structure for future ioctl operations by computing the xfs
+ * geometry for @xfd->fd.  Returns zero or a positive error code.
+ */
+int
+xfd_prepare_geometry(
+       struct xfs_fd           *xfd)
+{
+       return xfrog_geometry(xfd->fd, &xfd->fsgeom);
+}
+
+/*
+ * Release any resources associated with this xfs_fd structure.  Returns zero
+ * or a positive error code.
+ */
+int
+xfd_close(
+       struct xfs_fd           *xfd)
+{
+       int                     ret = 0;
+
+       if (xfd->fd < 0)
+               return 0;
+
+       ret = close(xfd->fd);
+       xfd->fd = -1;
+       if (ret < 0)
+               return errno;
+
+       return 0;
+}