summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-11-27 20:31:36 -0500
committerTheodore Ts'o <tytso@mit.edu>2011-11-27 22:40:24 -0500
commit2f7d855c632a5dd507669abc90ec452635a4a248 (patch)
treecd4e7bc8d38e8085aac86b7745b7168bef58b03e
parent66df14687d6a905aa111ec7327357a3ae1ad3236 (diff)
downloade2fsprogs-2f7d855c632a5dd507669abc90ec452635a4a248.tar.gz
libquota: remove use of PATH_MAX and replace it with QUOTA_NAME_LEN
PATH_MAX is not portable (for example, it doesn't exist on the Hurd). So replace it with a new define, which defines the maximum length of the base quota name. As it turns out, this is substantially smaller than PATH_MAX. Also move the definitions relating to quotaio.c from mkquota.h to quotaio.h, as a cleanup. Addresses-Debian-Bug: #649689 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--e2fsck/quota.c3
-rw-r--r--lib/quota/mkquota.h5
-rw-r--r--lib/quota/quotaio.c4
-rw-r--r--lib/quota/quotaio.h8
4 files changed, 12 insertions, 8 deletions
diff --git a/e2fsck/quota.c b/e2fsck/quota.c
index 53b695b9..3ae934a0 100644
--- a/e2fsck/quota.c
+++ b/e2fsck/quota.c
@@ -16,6 +16,7 @@
#include "e2fsck.h"
#include "problem.h"
#include "quota/mkquota.h"
+#include "quota/quotaio.h"
static void move_quota_inode(ext2_filsys fs, ext2_ino_t from_ino,
ext2_ino_t to_ino, int qtype)
@@ -24,7 +25,7 @@ static void move_quota_inode(ext2_filsys fs, ext2_ino_t from_ino,
ext2_ino_t ino;
struct ext2_inode inode;
errcode_t retval;
- char qf_name[255];
+ char qf_name[QUOTA_NAME_LEN];
if (ext2fs_read_inode(fs, from_ino, &inode))
return;
diff --git a/lib/quota/mkquota.h b/lib/quota/mkquota.h
index 4fbaedd0..a5fa74ba 100644
--- a/lib/quota/mkquota.h
+++ b/lib/quota/mkquota.h
@@ -60,9 +60,4 @@ int quota_is_on(ext2_filsys fs, int type);
int quota_file_exists(ext2_filsys fs, int qtype, int fmt);
void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, int qtype);
-/* In quotaio.c */
-const char *quota_get_qf_name(int type, int fmt, char *buf);
-const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt,
- char *path_buf, size_t path_buf_size);
-
#endif /* __QUOTA_QUOTAIO_H__ */
diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
index d0b5b9d8..3f434caa 100644
--- a/lib/quota/quotaio.c
+++ b/lib/quota/quotaio.c
@@ -56,7 +56,7 @@ const char *quota_get_qf_name(int type, int fmt, char *buf)
{
if (!buf)
return NULL;
- snprintf(buf, PATH_MAX, "%s.%s",
+ snprintf(buf, QUOTA_NAME_LEN, "%s.%s",
basenames[fmt], extensions[type]);
return buf;
@@ -66,7 +66,7 @@ const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt,
char *path_buf, size_t path_buf_size)
{
struct stat qf_stat;
- char qf_name[PATH_MAX] = {0};
+ char qf_name[QUOTA_NAME_LEN];
if (!mntpt || !path_buf || !path_buf_size)
return NULL;
diff --git a/lib/quota/quotaio.h b/lib/quota/quotaio.h
index f8cc1f1d..91a1ff27 100644
--- a/lib/quota/quotaio.h
+++ b/lib/quota/quotaio.h
@@ -159,4 +159,12 @@ const char *type2name(int type);
void update_grace_times(struct dquot *q);
+/* size for the buffer returned by quota_get_qf_name(); must be greater
+ than maxlen of extensions[] and fmtnames[] (plus 2) found in quotaio.c */
+#define QUOTA_NAME_LEN 16
+
+const char *quota_get_qf_name(int type, int fmt, char *buf);
+const char *quota_get_qf_path(const char *mntpt, int qtype, int fmt,
+ char *path_buf, size_t path_buf_size);
+
#endif /* GUARD_QUOTAIO_H */