diff options
author | David Howells <dhowells@redhat.com> | 2015-01-21 15:03:40 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-02-17 12:21:51 -0500 |
commit | e59b4e9187bd5175b9845dc10fedb0879b7efbfd (patch) | |
tree | d1194fe02bcb93cd0fbf4924c9756158717338e9 /fs/debugfs | |
parent | 77b3da6e3232d3b4d4b8addb4b05799fe98f3bf8 (diff) |
debugfs: Provide a file creation function that also takes an initial size
Provide a file creation function that also takes an initial size so that the
caller doesn't have to set i_size, thus meaning that we don't have to call
deal with ->d_inode in the callers.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/debugfs')
-rw-r--r-- | fs/debugfs/inode.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 957c40ce09f6..45b18a5e225c 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c | |||
@@ -338,6 +338,46 @@ struct dentry *debugfs_create_file(const char *name, umode_t mode, | |||
338 | EXPORT_SYMBOL_GPL(debugfs_create_file); | 338 | EXPORT_SYMBOL_GPL(debugfs_create_file); |
339 | 339 | ||
340 | /** | 340 | /** |
341 | * debugfs_create_file_size - create a file in the debugfs filesystem | ||
342 | * @name: a pointer to a string containing the name of the file to create. | ||
343 | * @mode: the permission that the file should have. | ||
344 | * @parent: a pointer to the parent dentry for this file. This should be a | ||
345 | * directory dentry if set. If this parameter is NULL, then the | ||
346 | * file will be created in the root of the debugfs filesystem. | ||
347 | * @data: a pointer to something that the caller will want to get to later | ||
348 | * on. The inode.i_private pointer will point to this value on | ||
349 | * the open() call. | ||
350 | * @fops: a pointer to a struct file_operations that should be used for | ||
351 | * this file. | ||
352 | * @file_size: initial file size | ||
353 | * | ||
354 | * This is the basic "create a file" function for debugfs. It allows for a | ||
355 | * wide range of flexibility in creating a file, or a directory (if you want | ||
356 | * to create a directory, the debugfs_create_dir() function is | ||
357 | * recommended to be used instead.) | ||
358 | * | ||
359 | * This function will return a pointer to a dentry if it succeeds. This | ||
360 | * pointer must be passed to the debugfs_remove() function when the file is | ||
361 | * to be removed (no automatic cleanup happens if your module is unloaded, | ||
362 | * you are responsible here.) If an error occurs, %NULL will be returned. | ||
363 | * | ||
364 | * If debugfs is not enabled in the kernel, the value -%ENODEV will be | ||
365 | * returned. | ||
366 | */ | ||
367 | struct dentry *debugfs_create_file_size(const char *name, umode_t mode, | ||
368 | struct dentry *parent, void *data, | ||
369 | const struct file_operations *fops, | ||
370 | loff_t file_size) | ||
371 | { | ||
372 | struct dentry *de = debugfs_create_file(name, mode, parent, data, fops); | ||
373 | |||
374 | if (de) | ||
375 | de->d_inode->i_size = file_size; | ||
376 | return de; | ||
377 | } | ||
378 | EXPORT_SYMBOL_GPL(debugfs_create_file_size); | ||
379 | |||
380 | /** | ||
341 | * debugfs_create_dir - create a directory in the debugfs filesystem | 381 | * debugfs_create_dir - create a directory in the debugfs filesystem |
342 | * @name: a pointer to a string containing the name of the directory to | 382 | * @name: a pointer to a string containing the name of the directory to |
343 | * create. | 383 | * create. |