xref: /aosp_15_r20/external/libfuse/Android.patch (revision 9e5649576b786774a32d7b0252c9cd8c6538fa49)
1diff --git a/Android.patch b/Android.patch
2new file mode 100644
3index 0000000..e69de29
4diff --git a/include/fuse_kernel.h b/include/fuse_kernel.h
5index 2971d29..8a45f42 100644
6--- a/include/fuse_kernel.h
7+++ b/include/fuse_kernel.h
8@@ -425,6 +425,9 @@ enum fuse_opcode {
9
10 	/* CUSE specific operations */
11 	CUSE_INIT		= 4096,
12+
13+        /* Android specific operations */
14+        FUSE_CANONICAL_PATH     = 2016,
15 };
16
17 enum fuse_notify_code {
18diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h
19index 18c6363..e81c282 100644
20--- a/include/fuse_lowlevel.h
21+++ b/include/fuse_lowlevel.h
22@@ -317,6 +317,18 @@ struct fuse_lowlevel_ops {
23 	 */
24 	void (*readlink) (fuse_req_t req, fuse_ino_t ino);
25
26+        /**
27+	 * Return canonical path for inotify
28+	 *
29+	 * Valid replies:
30+	 *   fuse_reply_canonical_path
31+	 *   fuse_reply_err
32+	 *
33+	 * @param req request handle
34+	 * @param ino the inode number
35+	 */
36+	void (*canonical_path) (fuse_req_t req, fuse_ino_t ino);
37+
38 	/**
39 	 * Create file node
40 	 *
41@@ -1337,6 +1349,18 @@ int fuse_reply_attr(fuse_req_t req, const struct stat *attr,
42  */
43 int fuse_reply_readlink(fuse_req_t req, const char *link);
44
45+/**
46+ * Reply with the canonical path for inotify
47+ *
48+ * Possible requests:
49+ *   canonical_path
50+ *
51+ * @param req request handle
52+ * @param path to canonicalize
53+ * @return zero for success, -errno for failure to send reply
54+ */
55+int fuse_reply_canonical_path(fuse_req_t req, const char *path);
56+
57 /**
58  * Reply with open parameters
59  *
60diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
61index f2d7038..334b497 100644
62--- a/lib/fuse_lowlevel.c
63+++ b/lib/fuse_lowlevel.c
64@@ -450,6 +450,11 @@ int fuse_reply_readlink(fuse_req_t req, const char *linkname)
65 	return send_reply_ok(req, linkname, strlen(linkname));
66 }
67
68+int fuse_reply_canonical_path(fuse_req_t req, const char *path)
69+{
70+	return send_reply_ok(req, path, strlen(path));
71+}
72+
73 int fuse_reply_open(fuse_req_t req, const struct fuse_file_info *f)
74 {
75 	struct fuse_open_out arg;
76@@ -1202,6 +1207,16 @@ static void do_readlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
77 		fuse_reply_err(req, ENOSYS);
78 }
79
80+static void do_canonical_path(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
81+{
82+	(void) inarg;
83+
84+	if (req->se->op.canonical_path)
85+		req->se->op.canonical_path(req, nodeid);
86+	else
87+		fuse_reply_err(req, ENOSYS);
88+}
89+
90 static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
91 {
92 	struct fuse_mknod_in *arg = (struct fuse_mknod_in *) inarg;
93@@ -2456,6 +2471,7 @@ static struct {
94 	[FUSE_GETATTR]	   = { do_getattr,     "GETATTR"     },
95 	[FUSE_SETATTR]	   = { do_setattr,     "SETATTR"     },
96 	[FUSE_READLINK]	   = { do_readlink,    "READLINK"    },
97+        [FUSE_CANONICAL_PATH] = { do_canonical_path, "CANONICAL_PATH" },
98 	[FUSE_SYMLINK]	   = { do_symlink,     "SYMLINK"     },
99 	[FUSE_MKNOD]	   = { do_mknod,       "MKNOD"	     },
100 	[FUSE_MKDIR]	   = { do_mkdir,       "MKDIR"	     },
101diff --git a/lib/fuse_versionscript b/lib/fuse_versionscript
102index d18ba29..4c075a3 100644
103--- a/lib/fuse_versionscript
104+++ b/lib/fuse_versionscript
105@@ -163,6 +163,7 @@ FUSE_3.7 {
106 	global:
107 		fuse_set_log_func;
108 		fuse_log;
109+		fuse_reply_canonical_path;
110 } FUSE_3.3;
111
112 # Local Variables:
113