Browse Source

qcacmn: Add QDF file permissions

Add file permissions and a function to map that to Linux OS. Also
define a type for __qdf_dentry_t and __qdf_debugfs_file_t.

Change-Id: I91b293b262d955324e65157909ca9d3b831e2cf6
CRs-Fixed: 2097140
Mahesh Kumar Kalikot Veetil 7 years ago
parent
commit
164ecb724a
3 changed files with 54 additions and 0 deletions
  1. 11 0
      qdf/inc/qdf_debugfs.h
  2. 22 0
      qdf/linux/src/i_qdf_debugfs.h
  3. 21 0
      qdf/linux/src/qdf_debugfs.c

+ 11 - 0
qdf/inc/qdf_debugfs.h

@@ -28,6 +28,17 @@
 #include <i_qdf_debugfs.h>
 
 #ifdef WLAN_DEBUGFS
+
+/* qdf file modes */
+#define QDF_FILE_USR_READ	00400
+#define QDF_FILE_USR_WRITE	00200
+
+#define QDF_FILE_GRP_READ	00040
+#define QDF_FILE_GRP_WRITE	00020
+
+#define QDF_FILE_OTH_READ	00004
+#define QDF_FILE_OTH_WRITE	00002
+
 /**
  * qdf_debugfs_init() - initialize debugfs
  *

+ 22 - 0
qdf/linux/src/i_qdf_debugfs.h

@@ -28,9 +28,31 @@
 #include <linux/fs.h>
 #include <linux/debugfs.h>
 
+typedef struct dentry *__qdf_dentry_t;
+typedef struct seq_file *__qdf_debugfs_file_t;
+
 #ifdef WLAN_DEBUGFS
 
+/**
+ * qdf_debugfs_get_root() - get debugfs root
+ *
+ * Return: dentry * or NULL in case of failure
+ */
 struct dentry *qdf_debugfs_get_root(void);
 
+/**
+ * qdf_debugfs_get_filemode() - get Linux specific file mode
+ * @mode: This is a bitmap of file modes,
+ *		QDF_FILE_USR_READ
+ *		QDF_FILE_USR_WRITE
+ *		QDF_FILE_OTH_READ
+ *		QDF_FILE_OTH_WRITE
+ *		QDF_FILE_GRP_READ
+ *		QDF_FILE_GRP_WRITE
+ *
+ * Return: Linux specific file mode
+ */
+umode_t qdf_debugfs_get_filemode(uint16_t mode);
+
 #endif /* WLAN_DEBUGFS */
 #endif /* _I_QDF_DEBUGFS_H */

+ 21 - 0
qdf/linux/src/qdf_debugfs.c

@@ -52,3 +52,24 @@ struct dentry *qdf_debugfs_get_root(void)
 	return qdf_debugfs_root;
 }
 
+umode_t qdf_debugfs_get_filemode(uint16_t mode)
+{
+	umode_t ret = 0;
+
+	if (mode & QDF_FILE_USR_READ)
+		ret |= 0400;
+	if (mode & QDF_FILE_USR_WRITE)
+		ret |= 0200;
+
+	if (mode & QDF_FILE_GRP_READ)
+		ret |= 0040;
+	if (mode & QDF_FILE_GRP_WRITE)
+		ret |= 0020;
+
+	if (mode & QDF_FILE_OTH_READ)
+		ret |= 0004;
+	if (mode & QDF_FILE_OTH_WRITE)
+		ret |= 0002;
+
+	return ret;
+}