LLAPI\_HSM\_STATE\_SET(3) Lustre Library Functions LLAPI\_HSM\_STATE\_SET(3)

# [NAME](#NAME)

llapi\_hsm\_state\_set, llapi\_hsm\_state\_set\_fd - set HSM flags for a file on Lustre filesystem

# [SYNOPSIS](#SYNOPSIS)

```
#include <lustre/lustreapi.h>
```

```
int llapi_hsm_state_set(const char *path, __u64 setmask,
                        __u64 clearmask, __u32 archive_id);
```

```
int llapi_hsm_state_set_fd(int fd, __u64 setmask,
                           __u64 clearmask, __u32 archive_id);
```

# [DESCRIPTION](#DESCRIPTION)

**llapi\_hsm\_state\_set()** **llapi\_hsm\_state\_set\_fd()** sets, clears HSM flags and modifies archive ID for file pointed by *path* or *fd*.

[*setmask*](#setmask)

Mask of flags to be added.

[*clearmask*](#clearmask)

Mask of flags to be removed.

[*archive\_id*](#archive_id)

Archive ID (greater than 0) used for this file. Use 0 if you do not want to change it.

See [**llapi\_hsm\_state\_get**(3)](/man/enterprise-packages/lustre/llapi_hsm_state_get.3) for available flags.

# [RETURN VALUES](#RETURN_VALUES)

**llapi\_hsm\_state\_set()** and **llapi\_hsm\_state\_set\_fd()** return:

0

on success

!= 0

on failure, *errno* is set appropriately.

# [ERRORS](#ERRORS)

[**-ENOMEM**](#ENOMEM)

failed to allocate memory.

[**-ENAMETOOLONG**](#ENAMETOOLONG)

*path* was too long.

[**-ENOENT**](#ENOENT)

*path* does not point to a file or a directory.

[**-ENOTTY**](#ENOTTY)

*path* does not point to a Lustre filesystem.

[**-EINVAL**](#EINVAL)

Provided masks resulted in an incompatible set of flags.

# [EXAMPLES](#EXAMPLES)

```
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <lustre/lustreapi.h>
int main(int argc, char **argv)
{
	int rc;
	if (argc < 2) {
		fprintf(stderr, "usage: prog FILEPATH\n");
		exit(1);
	}
	rc = llapi_hsm_state_set(argv[1], HS_DIRTY|HS_NORELEASE, 0, 0);
	if (rc != 0) {
		fprintf(stderr, "Can't change hsm flags for %s: %s\n",
			argv[1], strerror(errno = -rc));
		exit(rc);
	}
	exit(0);
}
```

# [AVAILABILITY](#AVAILABILITY)

**llapi\_hsm\_state\_set** and **llapi\_hsm\_state\_set\_fd** are part of the [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7) user application interface library since release 2.4.0

# [SEE ALSO](#SEE_ALSO)

[**llapi\_hsm\_state\_get**(3)](/man/enterprise-packages/lustre/llapi_hsm_state_get.3), [**llapi\_hsm\_state\_get\_fd**(3)](/man/enterprise-packages/lustre/llapi_hsm_state_get_fd.3), [**lustre**(7)](/man/enterprise-packages/lustre/lustre.7), [**lustreapi**(7)](/man/enterprise-packages/lustre/lustreapi.7)

2024-08-27 Lustre User API

---

Document: llapi_hsm_state_set(3) from lustre 2.17.59-r1 (Chainguard OS)
Source: https://github.com/lustre/lustre-release
