diff options
| author | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-21 12:25:15 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-21 12:25:15 -0500 |
| commit | 08a4ecee986dd98e86090ff5faac4782b6765aed (patch) | |
| tree | 74df5de49f38c432a6a18303b0c6d834fd09028f /fs/debugfs | |
| parent | ba93c6297b9cfad5a70b5e5ed13c9dbead6601d3 (diff) | |
| parent | b3229087c5e08589cea4f5040dab56f7dc11332a (diff) | |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: (23 commits)
[PATCH] sysfs: fix a kobject leak in sysfs_add_link on the error path
[PATCH] sysfs: don't export dir symbols
[PATCH] get_cpu_sysdev() signedness fix
[PATCH] kobject_add_dir
[PATCH] debugfs: Add debugfs_create_blob() helper for exporting binary data
[PATCH] sysfs: fix problem with duplicate sysfs directories and files
[PATCH] Kobject: kobject.h: fix a typo
[PATCH] Kobject: provide better warning messages when people do stupid things
[PATCH] Driver core: add macros notice(), dev_notice()
[PATCH] firmware: fix BUG: in fw_realloc_buffer
[PATCH] sysfs: kzalloc conversion
[PATCH] fix module sysfs files reference counting
[PATCH] add EXPORT_SYMBOL_GPL_FUTURE() to USB subsystem
[PATCH] add EXPORT_SYMBOL_GPL_FUTURE() to RCU subsystem
[PATCH] add EXPORT_SYMBOL_GPL_FUTURE()
[PATCH] Clean up module.c symbol searching logic
[PATCH] kobj_map semaphore to mutex conversion
[PATCH] kref: avoid an atomic operation in kref_put()
[PATCH] handle errors returned by platform_get_irq*()
[PATCH] driver core: platform_get_irq*(): return -ENXIO on error
...
Diffstat (limited to 'fs/debugfs')
| -rw-r--r-- | fs/debugfs/file.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index d575452cd9f7..40c4fc973fad 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c | |||
| @@ -251,3 +251,49 @@ struct dentry *debugfs_create_bool(const char *name, mode_t mode, | |||
| 251 | } | 251 | } |
| 252 | EXPORT_SYMBOL_GPL(debugfs_create_bool); | 252 | EXPORT_SYMBOL_GPL(debugfs_create_bool); |
| 253 | 253 | ||
| 254 | static ssize_t read_file_blob(struct file *file, char __user *user_buf, | ||
| 255 | size_t count, loff_t *ppos) | ||
| 256 | { | ||
| 257 | struct debugfs_blob_wrapper *blob = file->private_data; | ||
| 258 | return simple_read_from_buffer(user_buf, count, ppos, blob->data, | ||
| 259 | blob->size); | ||
| 260 | } | ||
| 261 | |||
| 262 | static struct file_operations fops_blob = { | ||
| 263 | .read = read_file_blob, | ||
| 264 | .open = default_open, | ||
| 265 | }; | ||
| 266 | |||
| 267 | /** | ||
| 268 | * debugfs_create_blob - create a file in the debugfs filesystem that is | ||
| 269 | * used to read and write a binary blob. | ||
| 270 | * | ||
| 271 | * @name: a pointer to a string containing the name of the file to create. | ||
| 272 | * @mode: the permission that the file should have | ||
| 273 | * @parent: a pointer to the parent dentry for this file. This should be a | ||
| 274 | * directory dentry if set. If this paramater is NULL, then the | ||
| 275 | * file will be created in the root of the debugfs filesystem. | ||
| 276 | * @blob: a pointer to a struct debugfs_blob_wrapper which contains a pointer | ||
| 277 | * to the blob data and the size of the data. | ||
| 278 | * | ||
| 279 | * This function creates a file in debugfs with the given name that exports | ||
| 280 | * @blob->data as a binary blob. If the @mode variable is so set it can be | ||
| 281 | * read from. Writing is not supported. | ||
| 282 | * | ||
| 283 | * This function will return a pointer to a dentry if it succeeds. This | ||
| 284 | * pointer must be passed to the debugfs_remove() function when the file is | ||
| 285 | * to be removed (no automatic cleanup happens if your module is unloaded, | ||
| 286 | * you are responsible here.) If an error occurs, NULL will be returned. | ||
| 287 | * | ||
| 288 | * If debugfs is not enabled in the kernel, the value -ENODEV will be | ||
| 289 | * returned. It is not wise to check for this value, but rather, check for | ||
| 290 | * NULL or !NULL instead as to eliminate the need for #ifdef in the calling | ||
| 291 | * code. | ||
| 292 | */ | ||
| 293 | struct dentry *debugfs_create_blob(const char *name, mode_t mode, | ||
| 294 | struct dentry *parent, | ||
| 295 | struct debugfs_blob_wrapper *blob) | ||
| 296 | { | ||
| 297 | return debugfs_create_file(name, mode, parent, blob, &fops_blob); | ||
| 298 | } | ||
| 299 | EXPORT_SYMBOL_GPL(debugfs_create_blob); | ||
