+ return rc;
+}
+
+/**
+ * Set HSM states of file pointed by \a path.
+ *
+ * see llapi_hsm_state_set_fd() for args use and return
+ */
+int llapi_hsm_state_set(const char *path, __u64 setmask, __u64 clearmask,
+ __u32 archive_id)
+{
+ int fd;
+ int rc;
+
+ fd = open(path, O_WRONLY | O_LOV_DELAY_CREATE | O_NONBLOCK);
+ if (fd < 0)
+ return -errno;
+
+ rc = llapi_hsm_state_set_fd(fd, setmask, clearmask, archive_id);
+
+ close(fd);
+ return rc;
+}
+
+/**
+ * Return the current HSM request related to file pointed by \a path.
+ *
+ * \param hca Should be allocated by caller. Will be filled with current file
+ * actions.
+ *
+ * \retval 0 on success.
+ * \retval -errno on error.
+ */
+int llapi_hsm_current_action(const char *path, struct hsm_current_action *hca)
+{
+ int fd;
+ int rc;
+
+ fd = open(path, O_RDONLY | O_NONBLOCK);
+ if (fd < 0)
+ return -errno;
+
+ rc = ioctl(fd, LL_IOC_HSM_ACTION, hca);
+ /* If error, save errno value */
+ rc = rc ? -errno : 0;
+
+ close(fd);
+ return rc;
+}
+
+/**
+ * Allocate a hsm_user_request with the specified carateristics.
+ * This structure should be freed with free().
+ *
+ * \return an allocated structure on success, NULL otherwise.
+ */
+struct hsm_user_request *llapi_hsm_user_request_alloc(int itemcount,
+ int data_len)
+{
+ int len = 0;
+
+ len += sizeof(struct hsm_user_request);
+ len += sizeof(struct hsm_user_item) * itemcount;
+ len += data_len;
+
+ return (struct hsm_user_request *)malloc(len);
+}
+
+/**
+ * Send a HSM request to Lustre, described in \param request.
+ *
+ * \param path Fullpath to the file to operate on.
+ * \param request The request, allocated with llapi_hsm_user_request_alloc().
+ *
+ * \return 0 on success, an error code otherwise.
+ */
+int llapi_hsm_request(const char *path, const struct hsm_user_request *request)
+{
+ int rc;
+ int fd;
+
+ rc = get_root_path(WANT_FD, NULL, &fd, (char *)path, -1);
+ if (rc)
+ return rc;
+
+ rc = ioctl(fd, LL_IOC_HSM_REQUEST, request);
+ /* If error, save errno value */
+ rc = rc ? -errno : 0;
+