/*
 * vdevadm — vdev administration tool (udevadm-like interface)
 * Copyright (C) 2026  Aitor C.Z. <aitor_czr@gnuinos.org>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#ifndef VDEVADM_H
#define VDEVADM_H

#include <stddef.h>

#define VDEVADM_VERSION "1.4.7"

struct vdevadm_ctx {
	char mountpoint[4096];
	char udev_root[4096];
	char state_dir[4096];
	char sysfs[4096];
	char ctrl_socket[4096];
};

struct vdevadm_cmd {
	const char *name;
	const char *help;
	int (*cmd)(struct vdevadm_ctx *ctx, int argc, char *argv[]);
};

int vdevadm_ctx_init(struct vdevadm_ctx *ctx);
void vdevadm_ctx_dump(const struct vdevadm_ctx *ctx);

int vdevadm_device_id_from_path(struct vdevadm_ctx *ctx, const char *path,
								char *id_out, size_t id_len);
int vdevadm_device_db_path(struct vdevadm_ctx *ctx, const char *device_id,
						   char *path_out, size_t path_len);

int vdevadm_info_main(struct vdevadm_ctx *ctx, int argc, char *argv[]);
int vdevadm_trigger_main(struct vdevadm_ctx *ctx, int argc, char *argv[]);
int vdevadm_settle_main(struct vdevadm_ctx *ctx, int argc, char *argv[]);
int vdevadm_control_main(struct vdevadm_ctx *ctx, int argc, char *argv[]);
int vdevadm_monitor_main(struct vdevadm_ctx *ctx, int argc, char *argv[]);

int vdevadm_fifo_cmd(const char *ctl_path, const char *rsp_path,
					 const char *command, char *buf, size_t buflen);

#endif /* VDEVADM_H */
