summaryrefslogtreecommitdiffstats
path: root/drivers/block/loop/loop_file_fmt.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/loop/loop_file_fmt.h')
-rw-r--r--drivers/block/loop/loop_file_fmt.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/drivers/block/loop/loop_file_fmt.h b/drivers/block/loop/loop_file_fmt.h
new file mode 100644
index 000000000000..f5989b95cfac
--- /dev/null
+++ b/drivers/block/loop/loop_file_fmt.h
@@ -0,0 +1,88 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * loop_file_fmt.h
+ *
+ * File format subsystem for the loop device module.
+ *
+ * Copyright (C) 2019 Manuel Bentele
+ */
+
+#ifndef _LINUX_LOOP_FILE_FMT_H
+#define _LINUX_LOOP_FILE_FMT_H
+
+#include "loop_main.h"
+
+struct loop_file_fmt;
+
+/* data structure representing the file format subsystem interface */
+struct loop_file_fmt_ops {
+ int (*init) (struct loop_file_fmt *lo_fmt);
+ void (*exit) (struct loop_file_fmt *lo_fmt);
+
+ int (*read) (struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+ int (*write) (struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+ int (*read_aio) (struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+ int (*write_aio) (struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+ int (*discard) (struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+
+ int (*flush) (struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+};
+
+/* data structure for implementing file format drivers */
+struct loop_file_fmt_driver {
+ const char *name;
+ const __u32 file_fmt_type;
+ struct loop_file_fmt_ops *ops;
+ struct module *owner;
+};
+
+/* data structure for using with the file format subsystem */
+struct loop_file_fmt {
+ __u32 file_fmt_type;
+ struct loop_device *lo;
+ void *private_data;
+};
+
+/* subsystem functions for the driver implementation */
+extern int loop_file_fmt_register_driver(struct loop_file_fmt_driver *drv);
+extern void loop_file_fmt_unregister_driver(struct loop_file_fmt_driver *drv);
+
+/* subsystem functions for subsystem usage */
+extern struct loop_file_fmt *loop_file_fmt_alloc(void);
+extern void loop_file_fmt_free(struct loop_file_fmt *lo_fmt);
+
+extern int loop_file_fmt_set_lo(struct loop_file_fmt *lo_fmt,
+ struct loop_device *lo);
+extern struct loop_device *loop_file_fmt_get_lo(struct loop_file_fmt *lo_fmt);
+
+extern int loop_file_fmt_init(struct loop_file_fmt *lo_fmt);
+extern void loop_file_fmt_exit(struct loop_file_fmt *lo_fmt);
+
+extern int loop_file_fmt_read(struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+extern int loop_file_fmt_read_aio(struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+extern int loop_file_fmt_write(struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+extern int loop_file_fmt_write_aio(struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+extern int loop_file_fmt_discard(struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+
+extern int loop_file_fmt_flush(struct loop_file_fmt *lo_fmt,
+ struct request *rq);
+
+extern int loop_file_fmt_change(struct loop_file_fmt *lo_fmt,
+ __u32 file_fmt_type_new);
+
+/* helper functions of the subsystem */
+extern ssize_t loop_file_fmt_print_type(__u32 file_fmt_type,
+ char *file_fmt_name);
+
+#endif