diff options
author | Joel Becker <joel.becker@oracle.com> | 2007-06-22 16:07:02 -0400 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2007-07-10 19:52:22 -0400 |
commit | b23cdde4c6240d70bb3d2e3c4046b60d6f6c8451 (patch) | |
tree | ed1965f424197194def20aa1ed10867f9fac6836 /fs | |
parent | 4c75f7416f51b0c6855952467a5db04f9c598f09 (diff) |
configfs: consistent attribute size
The attribute store/show code currently limits attributes at PAGE_SIZE.
This code comes from sysfs, where it still works that way.
However, PAGE_SIZE is not constant. A 16k attribute string works on
ia64 but not on x86. Really a subsystem shouldn't allow different
attribute sizes based on platform.
As such, limit all simple attributes to 4k. This works on all
platforms, and is consistent with all current code.
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/configfs/file.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/fs/configfs/file.c b/fs/configfs/file.c index 3527c7c6def8..0f4b65e85245 100644 --- a/fs/configfs/file.c +++ b/fs/configfs/file.c | |||
@@ -33,6 +33,13 @@ | |||
33 | #include <linux/configfs.h> | 33 | #include <linux/configfs.h> |
34 | #include "configfs_internal.h" | 34 | #include "configfs_internal.h" |
35 | 35 | ||
36 | /* | ||
37 | * A simple attribute can only be 4096 characters. Why 4k? Because the | ||
38 | * original code limited it to PAGE_SIZE. That's a bad idea, though, | ||
39 | * because an attribute of 16k on ia64 won't work on x86. So we limit to | ||
40 | * 4k, our minimum common page size. | ||
41 | */ | ||
42 | #define SIMPLE_ATTR_SIZE 4096 | ||
36 | 43 | ||
37 | struct configfs_buffer { | 44 | struct configfs_buffer { |
38 | size_t count; | 45 | size_t count; |
@@ -69,7 +76,7 @@ static int fill_read_buffer(struct dentry * dentry, struct configfs_buffer * buf | |||
69 | 76 | ||
70 | count = ops->show_attribute(item,attr,buffer->page); | 77 | count = ops->show_attribute(item,attr,buffer->page); |
71 | buffer->needs_read_fill = 0; | 78 | buffer->needs_read_fill = 0; |
72 | BUG_ON(count > (ssize_t)PAGE_SIZE); | 79 | BUG_ON(count > (ssize_t)SIMPLE_ATTR_SIZE); |
73 | if (count >= 0) | 80 | if (count >= 0) |
74 | buffer->count = count; | 81 | buffer->count = count; |
75 | else | 82 | else |
@@ -137,8 +144,8 @@ fill_write_buffer(struct configfs_buffer * buffer, const char __user * buf, size | |||
137 | if (!buffer->page) | 144 | if (!buffer->page) |
138 | return -ENOMEM; | 145 | return -ENOMEM; |
139 | 146 | ||
140 | if (count >= PAGE_SIZE) | 147 | if (count >= SIMPLE_ATTR_SIZE) |
141 | count = PAGE_SIZE - 1; | 148 | count = SIMPLE_ATTR_SIZE - 1; |
142 | error = copy_from_user(buffer->page,buf,count); | 149 | error = copy_from_user(buffer->page,buf,count); |
143 | buffer->needs_read_fill = 1; | 150 | buffer->needs_read_fill = 1; |
144 | /* if buf is assumed to contain a string, terminate it by \0, | 151 | /* if buf is assumed to contain a string, terminate it by \0, |