OS Manuals

llapi_unlink_foreign(3)

llapi_unlink_foreign - unlink file/dir with foreign layout on a Lustre filesystem

LLAPI_UNLINK_FOREIGN(3) Lustre Library Functions LLAPI_UNLINK_FOREIGN(3)

llapi_unlink_foreign - unlink file/dir with foreign layout on a Lustre filesystem

#include <lustre/lustreapi.h>
int llapi_unlink_foreign(char *name);

llapi_unlink_foreign() will allow to unlink a file/dir of name with foreign LOV/LMV, that would be prevented to be using regular unlink/rmdir command/syscall. It also works for regular file/dir.

llapi_unlink_foreign() return:

=0
on success.
<0
on failure, the absolute value is an error code.

name does not exist.
name may not point to a Lustre filesystem.

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <lustre/lustreapi.h>
int main(int argc, char **argv)
{
	char *foreign = NULL;
	int c, rc;
	while ((c = getopt(argc, argv, "hf:")) != -1) {
		switch (c) {
		case 'f':
			foreign = optarg;
			break;
		case 'h':
		default:
			fprintf(stderr,
				"Usage: %s [-f <foreign file/dir pathname>]0,
				argv[0]);
			exit(0);
			break;
		}
	}
	if (foreign == NULL) {
		fprintf(stderr, "a foreign file/dir pathname must be provided0);
		exit(0);
	}
	rc = llapi_unlink_foreign(foreign);
	if (rc < 0)
		fprintf(stderr, "llapi_unlink_foreign() error: %d0, rc);
	return rc;
}

llapi_unlink_foreign() is part of the lustre(7) user application interface library since release 2.9.0

lustre(7), lustreapi(7)

2024-08-28 Lustre User API

lustre 2.17.59-r2 · enterprise-packages · ingested 2026-10-11