Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106993354
D37090.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D37090.diff
View Options
diff --git a/sys/compat/lindebugfs/lindebugfs.c b/sys/compat/lindebugfs/lindebugfs.c
--- a/sys/compat/lindebugfs/lindebugfs.c
+++ b/sys/compat/lindebugfs/lindebugfs.c
@@ -367,6 +367,35 @@
&fops_bool_ro, &fops_bool_wo);
}
+
+static int
+debugfs_u8_get(void *data, uint64_t *value)
+{
+ uint8_t *u8data = data;
+ *value = *u8data;
+ return (0);
+}
+
+static int
+debugfs_u8_set(void *data, uint64_t value)
+{
+ uint8_t *u8data = data;
+ *u8data = (uint8_t)value;
+ return (0);
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(fops_u8, debugfs_u8_get, debugfs_u8_set, "%u\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_u8_ro, debugfs_u8_get, NULL, "%u\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_u8_wo, NULL, debugfs_u8_set, "%u\n");
+
+void
+debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent, uint8_t *value)
+{
+ debugfs_create_mode_unsafe(name, mode, parent, value, &fops_u8,
+ &fops_u8_ro, &fops_u8_wo);
+}
+
+
static int
debugfs_ulong_get(void *data, uint64_t *value)
{
@@ -394,6 +423,43 @@
&fops_ulong_ro, &fops_ulong_wo);
}
+
+static ssize_t
+fops_blob_read(struct file *filp, char __user *ubuf, size_t read_size, loff_t *ppos)
+{
+ struct debugfs_blob_wrapper *blob;
+
+ blob = filp->private_data;
+ if (blob == NULL)
+ return (-EINVAL);
+ if (blob->size == 0 || blob->data == NULL)
+ return (-EINVAL);
+
+ return (simple_read_from_buffer(ubuf, read_size, ppos, blob->data, blob->size));
+}
+
+static int
+fops_blob_open(struct inode *inode, struct file *filp)
+{
+ return (simple_open(inode, filp));
+}
+
+static const struct file_operations __fops_blob_ro = {
+ .owner = THIS_MODULE,
+ .open = fops_blob_open,
+ .read = fops_blob_read,
+ .llseek = no_llseek
+};
+
+struct dentry *
+debugfs_create_blob(const char *name, umode_t mode, struct dentry *parent,
+ struct debugfs_blob_wrapper *value)
+{
+ /* Blobs are read-only. */
+ return (debugfs_create_file(name, mode & 0444, parent, value, &__fops_blob_ro));
+}
+
+
static int
lindebugfs_init(PFS_INIT_ARGS)
{
diff --git a/sys/compat/linuxkpi/common/include/linux/debugfs.h b/sys/compat/linuxkpi/common/include/linux/debugfs.h
--- a/sys/compat/linuxkpi/common/include/linux/debugfs.h
+++ b/sys/compat/linuxkpi/common/include/linux/debugfs.h
@@ -47,6 +47,11 @@
int nregs;
};
+struct debugfs_blob_wrapper {
+ void *data;
+ size_t size;
+};
+
struct dentry *debugfs_create_file(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops);
@@ -75,8 +80,12 @@
void debugfs_create_bool(const char *name, umode_t mode, struct dentry *parent,
bool *value);
-
+void debugfs_create_u8(const char *name, umode_t mode, struct dentry *parent,
+ uint8_t *value);
void debugfs_create_ulong(const char *name, umode_t mode, struct dentry *parent,
unsigned long *value);
+struct dentry *debugfs_create_blob(const char *name, umode_t mode,
+ struct dentry *parent, struct debugfs_blob_wrapper *value);
+
#endif /* _LINUXKPI_LINUX_DEBUGFS_H_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 4:35 PM (9 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15733430
Default Alt Text
D37090.diff (2 KB)
Attached To
Mode
D37090: LinuxKPI,lindebugfs: add more base type support
Attached
Detach File
Event Timeline
Log In to Comment