All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] libquota: remove get_qf_path()
@ 2011-10-04 16:16 Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 2/5] libquota: clean up some gcc -Wall warnings Theodore Ts'o
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Theodore Ts'o @ 2011-10-04 16:16 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Aditya Kali, Theodore Ts'o

This function isn't used anywhere, so remove it.  It also uses
PATH_MAX which is not portable.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/quota/mkquota.h |    2 --
 lib/quota/quotaio.c |   18 ------------------
 2 files changed, 0 insertions(+), 20 deletions(-)

diff --git a/lib/quota/mkquota.h b/lib/quota/mkquota.h
index b4eba14..00d3c2f 100644
--- a/lib/quota/mkquota.h
+++ b/lib/quota/mkquota.h
@@ -60,7 +60,5 @@ void set_sb_quota_inum(ext2_filsys fs, ext2_ino_t ino, int qtype);
 
 /* in quotaio.c */
 const char *get_qf_name(int type, int fmt, char *buf);
-const char *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 7e080c8..cf13e35 100644
--- a/lib/quota/quotaio.c
+++ b/lib/quota/quotaio.c
@@ -61,24 +61,6 @@ const char *get_qf_name(int type, int fmt, char *buf)
 	return buf;
 }
 
-const char *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};
-
-	BUG_ON(!mntpt);
-	BUG_ON(!path_buf);
-	BUG_ON(!path_buf_size);
-
-	strncpy(path_buf, mntpt, path_buf_size);
-	strncat(path_buf, "/", 1);
-	strncat(path_buf, get_qf_name(qtype, fmt, qf_name),
-		path_buf_size - strlen(path_buf));
-
-	return path_buf;
-}

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/5] libquota: clean up some gcc -Wall warnings
  2011-10-04 16:16 [PATCH 1/5] libquota: remove get_qf_path() Theodore Ts'o
@ 2011-10-04 16:16 ` Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 3/5] libquota: remove get_qf_name() Theodore Ts'o
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2011-10-04 16:16 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Aditya Kali, Theodore Ts'o

Remove unused variables, places where 'return' was used with no value
in a non-void function, missing function declarations, etc.  Don't
assume that all systems have quotactl(), and use <sys/quota.h> if it
exists to define the quotactl interfaces.

One of the unused variables also got rid of a non-portable use of
PATH_MAX.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 configure              |    4 ++--
 configure.in           |    4 ++--
 lib/config.h.in        |    6 ++++++
 lib/ext2fs/ext2fs.h    |    2 +-
 lib/quota/mkquota.c    |   17 ++++++++---------
 lib/quota/quota.h      |   36 ------------------------------------
 lib/quota/quotaio.c    |    7 -------
 lib/quota/quotaio.h    |    2 ++
 lib/quota/quotaio_v2.c |   16 ++++++++--------
 9 files changed, 29 insertions(+), 65 deletions(-)

diff --git a/configure b/configure
index 35dd5ce..6c8eb49 100755
--- a/configure
+++ b/configure
@@ -10316,7 +10316,7 @@ fi
 done
 
 fi
-for ac_header in dirent.h errno.h execinfo.h getopt.h malloc.h mntent.h paths.h semaphore.h setjmp.h signal.h stdarg.h stdint.h stdlib.h termios.h termio.h unistd.h utime.h linux/falloc.h linux/fd.h linux/major.h net/if_dl.h netinet/in.h sys/disklabel.h sys/file.h sys/ioctl.h sys/mkdev.h sys/mman.h sys/prctl.h sys/queue.h sys/resource.h sys/select.h sys/socket.h sys/sockio.h sys/stat.h sys/syscall.h sys/sysmacros.h sys/time.h sys/types.h sys/un.h sys/wait.h
+for ac_header in dirent.h errno.h execinfo.h getopt.h malloc.h mntent.h paths.h semaphore.h setjmp.h signal.h stdarg.h stdint.h stdlib.h termios.h termio.h unistd.h utime.h linux/falloc.h linux/fd.h linux/major.h net/if_dl.h netinet/in.h sys/disklabel.h sys/file.h sys/ioctl.h sys/mkdev.h sys/mman.h sys/prctl.h sys/queue.h sys/quota.h sys/resource.h sys/select.h sys/socket.h sys/sockio.h sys/stat.h sys/syscall.h sys/sysmacros.h sys/time.h sys/types.h sys/un.h sys/wait.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -10958,7 +10958,7 @@ if test "$ac_res" != no; then :
 fi
 
 fi
-for ac_func in chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit sync_file_range posix_fadvise fallocate fallocate64 blkid_probe_get_topology mbstowcs backtrace
+for ac_func in chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync quotactl strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit sync_file_range posix_fadvise fallocate fallocate64 blkid_probe_get_topology mbstowcs backtrace
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/configure.in b/configure.in
index 90a6eec..0b609bb 100644
--- a/configure.in
+++ b/configure.in
@@ -802,7 +802,7 @@ if test $cross_compiling = no; then
 else
   AC_CHECK_PROGS(BUILD_CC, gcc cc)
 fi
-AC_CHECK_HEADERS(dirent.h errno.h execinfo.h getopt.h malloc.h mntent.h paths.h semaphore.h setjmp.h signal.h stdarg.h stdint.h stdlib.h termios.h termio.h unistd.h utime.h linux/falloc.h linux/fd.h linux/major.h net/if_dl.h netinet/in.h sys/disklabel.h sys/file.h sys/ioctl.h sys/mkdev.h sys/mman.h sys/prctl.h sys/queue.h sys/resource.h sys/select.h sys/socket.h sys/sockio.h sys/stat.h sys/syscall.h sys/sysmacros.h sys/time.h sys/types.h sys/un.h sys/wait.h)
+AC_CHECK_HEADERS(dirent.h errno.h execinfo.h getopt.h malloc.h mntent.h paths.h semaphore.h setjmp.h signal.h stdarg.h stdint.h stdlib.h termios.h termio.h unistd.h utime.h linux/falloc.h linux/fd.h linux/major.h net/if_dl.h netinet/in.h sys/disklabel.h sys/file.h sys/ioctl.h sys/mkdev.h sys/mman.h sys/prctl.h sys/queue.h sys/quota.h sys/resource.h sys/select.h sys/socket.h sys/sockio.h sys/stat.h sys/syscall.h sys/sysmacros.h sys/time.h sys/types.h sys/un.h sys/wait.h)
 AC_CHECK_HEADERS(sys/disk.h sys/mount.h,,,
 [[
 #if HAVE_SYS_QUEUE_H
@@ -932,7 +932,7 @@ if test -n "$BLKID_CMT"; then
   AC_SEARCH_LIBS([blkid_probe_all], [blkid])
 fi
 dnl
-AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit sync_file_range posix_fadvise fallocate fallocate64 blkid_probe_get_topology mbstowcs backtrace)
+AC_CHECK_FUNCS(chflags getrusage llseek lseek64 open64 fstat64 ftruncate64 getmntinfo strtoull strcasecmp srandom jrand48 fchown mallinfo fdatasync quotactl strnlen strptime strdup sysconf pathconf posix_memalign memalign valloc __secure_getenv prctl mmap utime setresuid setresgid usleep nanosleep getdtablesize getrlimit sync_file_range posix_fadvise fallocate fallocate64 blkid_probe_get_topology mbstowcs backtrace)
 dnl
 dnl Check to see if -lsocket is required (solaris) to make something
 dnl that uses socket() to compile; this is needed for the UUID library
diff --git a/lib/config.h.in b/lib/config.h.in
index 04613d6..a58745e 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -281,6 +281,9 @@
 /* Define to 1 if you have the `putenv' function. */
 #undef HAVE_PUTENV
 
+/* Define to 1 if you have the `quotactl' function. */
+#undef HAVE_QUOTACTL
+
 /* Define to 1 if dirent has d_reclen */
 #undef HAVE_RECLEN_DIRENT
 
@@ -399,6 +402,9 @@
 /* Define to 1 if you have the <sys/queue.h> header file. */
 #undef HAVE_SYS_QUEUE_H
 
+/* Define to 1 if you have the <sys/quota.h> header file. */
+#undef HAVE_SYS_QUOTA_H
+
 /* Define to 1 if you have the <sys/resource.h> header file. */
 #undef HAVE_SYS_RESOURCE_H
 
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 7df0b0d..b04b0d1 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -1355,7 +1355,7 @@ errcode_t ext2fs_mmp_init(ext2_filsys fs);
 errcode_t ext2fs_mmp_start(ext2_filsys fs);
 errcode_t ext2fs_mmp_update(ext2_filsys fs);
 errcode_t ext2fs_mmp_stop(ext2_filsys fs);
-unsigned ext2fs_mmp_new_seq();
+unsigned ext2fs_mmp_new_seq(void);
 
 /* read_bb.c */
 extern errcode_t ext2fs_read_bb_inode(ext2_filsys fs,
diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
index 4316243..263b62b 100644
--- a/lib/quota/mkquota.c
+++ b/lib/quota/mkquota.c
@@ -6,6 +6,9 @@
 #include "config.h"
 #include <sys/types.h>
 #include <sys/stat.h>
+#ifdef HAVE_SYS_QUOTA_H
+#include <sys/quota.h>
+#endif
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
@@ -51,8 +54,10 @@ int is_quota_on(ext2_filsys fs, int type)
 	char tmp[1024];
 	qid_t id = (type == USRQUOTA) ? getuid() : getgid();
 
+#ifdef HAVE_QUOTACTL
 	if (!quotactl(QCMD(Q_V2_GETQUOTA, type), fs->device_name, id, tmp))
 		return 1;
+#endif
 	return 0;
 }
 
@@ -114,10 +119,8 @@ errcode_t remove_quota_inode(ext2_filsys fs, int qtype)
 
 static void write_dquots(dict_t *dict, struct quota_handle *qh)
 {
-	int		i = 0;
 	dnode_t		*n;
 	struct dquot	*dq;
-	__u32		key;
 
 	for (n = dict_first(dict); n; n = dict_next(dict, n)) {
 		dq = dnode_get(n);
@@ -131,16 +134,14 @@ static void write_dquots(dict_t *dict, struct quota_handle *qh)
 
 errcode_t write_quota_inode(quota_ctx_t qctx, int qtype)
 {
-	int		retval, i;
-	unsigned long	qf_inums[MAXQUOTAS];
-	struct dquot	*dquot;
+	int		retval = 0, i;
 	dict_t		*dict;
 	ext2_filsys	fs;
 	struct quota_handle *h;
 	int		fmt = QFMT_VFS_V1;
 
 	if (!qctx)
-		return;
+		return 0;
 
 	fs = qctx->fs;
 	h = smalloc(sizeof(struct quota_handle));
@@ -179,7 +180,6 @@ errcode_t write_quota_inode(quota_ctx_t qctx, int qtype)
 	}
 
 	ext2fs_write_bitmaps(fs);
-out:
 	free(h);
 	return retval;
 }
@@ -361,7 +361,6 @@ void quota_data_inodes(quota_ctx_t qctx, struct ext2_inode *inode,
 errcode_t compute_quota(quota_ctx_t qctx, int qtype)
 {
 	ext2_filsys fs;
-	const char *name = "lost+found";
 	ext2_ino_t ino;
 	errcode_t ret;
 	struct ext2_inode inode;
@@ -369,7 +368,7 @@ errcode_t compute_quota(quota_ctx_t qctx, int qtype)
 	ext2_inode_scan scan;
 
 	if (!qctx)
-		return;
+		return 0;
 
 	fs = qctx->fs;
 	ret = ext2fs_open_inode_scan(fs, 0, &scan);
diff --git a/lib/quota/quota.h b/lib/quota/quota.h
index cc6c98e..a943ec6 100644
--- a/lib/quota/quota.h
+++ b/lib/quota/quota.h
@@ -103,42 +103,6 @@ typedef int64_t qsize_t;	/* Type in which we store size limitations */
 #define QIF_DQBLKSIZE (1 << QIF_DQBLKSIZE_BITS)
 
 /*
- * Quota structure used for communication with userspace via quotactl
- * Following flags are used to specify which fields are valid
- */
-enum {
-	QIF_BLIMITS_B = 0,
-	QIF_SPACE_B,
-	QIF_ILIMITS_B,
-	QIF_INODES_B,
-	QIF_BTIME_B,
-	QIF_ITIME_B,
-};
-
-#define QIF_BLIMITS	(1 << QIF_BLIMITS_B)
-#define QIF_SPACE	(1 << QIF_SPACE_B)
-#define QIF_ILIMITS	(1 << QIF_ILIMITS_B)
-#define QIF_INODES	(1 << QIF_INODES_B)
-#define QIF_BTIME	(1 << QIF_BTIME_B)
-#define QIF_ITIME	(1 << QIF_ITIME_B)
-#define QIF_LIMITS	(QIF_BLIMITS | QIF_ILIMITS)
-#define QIF_USAGE	(QIF_SPACE | QIF_INODES)
-#define QIF_TIMES	(QIF_BTIME | QIF_ITIME)
-#define QIF_ALL		(QIF_LIMITS | QIF_USAGE | QIF_TIMES)
-
-struct if_dqblk {
-	__u64 dqb_bhardlimit;
-	__u64 dqb_bsoftlimit;
-	__u64 dqb_curspace;
-	__u64 dqb_ihardlimit;
-	__u64 dqb_isoftlimit;
-	__u64 dqb_curinodes;
-	__u64 dqb_btime;
-	__u64 dqb_itime;
-	__u32 dqb_valid;
-};
-
-/*
  * Structure used for setting quota information about file via quotactl
  * Following flags are used to specify which fields are valid
  */
diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
index cf13e35..ef92f5a 100644
--- a/lib/quota/quotaio.c
+++ b/lib/quota/quotaio.c
@@ -117,7 +117,6 @@ static int compute_num_blocks_proc(ext2_filsys fs, blk64_t *blocknr,
 void truncate_quota_inode(ext2_filsys fs, ext2_ino_t ino)
 {
 	struct ext2_inode inode;
-	int i;
 
 	if (ext2fs_read_inode(fs, ino, &inode))
 		return;
@@ -135,7 +134,6 @@ void truncate_quota_inode(ext2_filsys fs, ext2_ino_t ino)
 
 static ext2_off64_t compute_inode_size(ext2_filsys fs, ext2_ino_t ino)
 {
-	struct ext2_inode inode;
 	blk64_t num_blocks = 0;
 
 	ext2fs_block_iterate3(fs, ino,
@@ -241,14 +239,9 @@ static errcode_t init_new_quota_inode(ext2_filsys fs, ext2_ino_t ino)
  */
 int new_io(struct quota_handle *h, ext2_filsys fs, int type, int fmt)
 {
-	int fd = 0;
 	ext2_file_t e2_file;
-	const char *mnt_fsname;
-	char qf_name[PATH_MAX];
 	int err;
-	struct ext2_inode inode;
 	unsigned long qf_inum;
-	struct stat st;
 
 	if (fmt == -1)
 		fmt = QFMT_VFS_V1;
diff --git a/lib/quota/quotaio.h b/lib/quota/quotaio.h
index fd39b55..f2c34f2 100644
--- a/lib/quota/quotaio.h
+++ b/lib/quota/quotaio.h
@@ -160,4 +160,6 @@ void truncate_quota_inode(ext2_filsys fs, ext2_ino_t ino);
 
 const char *type2name(int type);
 
+void update_grace_times(struct dquot *q);
+
 #endif /* GUARD_QUOTAIO_H */
diff --git a/lib/quota/quotaio_v2.c b/lib/quota/quotaio_v2.c
index 660d463..35512c0 100644
--- a/lib/quota/quotaio_v2.c
+++ b/lib/quota/quotaio_v2.c
@@ -32,14 +32,14 @@ static int v2_scan_dquots(struct quota_handle *h,
 static int v2_report(struct quota_handle *h, int verbose);
 
 struct quotafile_ops quotafile_ops_2 = {
-check_file:	v2_check_file,
-init_io:	v2_init_io,
-new_io:		v2_new_io,
-write_info:	v2_write_info,
-read_dquot:	v2_read_dquot,
-commit_dquot:	v2_commit_dquot,
-scan_dquots:	v2_scan_dquots,
-report:	v2_report
+	.check_file	= v2_check_file,
+	.init_io 	= v2_init_io,
+	.new_io 	= v2_new_io,
+	.write_info	= v2_write_info,
+	.read_dquot	= v2_read_dquot,
+	.commit_dquot	= v2_commit_dquot,
+	.scan_dquots	= v2_scan_dquots,
+	.report		= v2_report,
 };
 
 #define getdqbuf() smalloc(V2_DQBLKSIZE)
-- 
1.7.4.1.22.gec8e1.dirty


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/5] libquota: remove get_qf_name()
  2011-10-04 16:16 [PATCH 1/5] libquota: remove get_qf_path() Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 2/5] libquota: clean up some gcc -Wall warnings Theodore Ts'o
@ 2011-10-04 16:16 ` Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 4/5] libquota: use ext2_loff_t instead of loff_t Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 5/5] libquota: remove NLS support Theodore Ts'o
  3 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2011-10-04 16:16 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Aditya Kali, Theodore Ts'o

The get_qf_name() function used PATH_MAX, which is non-portable.
Worse, it blindly assumed that PATH_MAX was the size of the buffer
passed to it --- which in the one and only place where it was used in
libquota, was a buffer declared to a fixed size 256 bytes.

Fix this by simply getting rid of the function altogether.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/quota/mkquota.c |    6 +++---
 lib/quota/mkquota.h |    5 +----
 lib/quota/quotaio.c |   12 ------------
 misc/tune2fs.c      |    4 ++--
 4 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
index 263b62b..35cac66 100644
--- a/lib/quota/mkquota.c
+++ b/lib/quota/mkquota.c
@@ -65,16 +65,16 @@ int is_quota_on(ext2_filsys fs, int type)
  * Returns 0 if not able to find the quota file, otherwise returns its
  * inode number.
  */
-int quota_file_exists(ext2_filsys fs, int qtype, int fmt)
+int quota_file_exists(ext2_filsys fs, int qtype)
 {
 	char qf_name[256];
 	errcode_t ret;
 	ext2_ino_t ino;
 
-	if (qtype >= MAXQUOTAS || fmt > QFMT_VFS_V1)
+	if (qtype >= MAXQUOTAS)
 		return -EINVAL;
 
-	get_qf_name(qtype, fmt, qf_name);
+	snprintf(qf_name, sizeof(qf_name), "aquota.%s", type2name(qtype));
 
 	ret = ext2fs_lookup(fs, EXT2_ROOT_INO, qf_name, strlen(qf_name), 0,
 			    &ino);
diff --git a/lib/quota/mkquota.h b/lib/quota/mkquota.h
index 00d3c2f..e3ec8c2 100644
--- a/lib/quota/mkquota.h
+++ b/lib/quota/mkquota.h
@@ -55,10 +55,7 @@ void release_quota_context(quota_ctx_t *qctx);
 
 errcode_t remove_quota_inode(ext2_filsys fs, int qtype);
 int is_quota_on(ext2_filsys fs, int type);
-int quota_file_exists(ext2_filsys fs, int qtype, int fmt);
+int quota_file_exists(ext2_filsys fs, int qtype);
 void set_sb_quota_inum(ext2_filsys fs, ext2_ino_t ino, int qtype);
 
-/* in quotaio.c */
-const char *get_qf_name(int type, int fmt, char *buf);
-
 #endif  /* __QUOTA_QUOTAIO_H__ */
diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
index ef92f5a..f651353 100644
--- a/lib/quota/quotaio.c
+++ b/lib/quota/quotaio.c
@@ -49,18 +49,6 @@ const char *type2name(int type)
 	return extensions[type];
 }
 
-/**
- * Creates a quota file name for given type and format.
- */
-const char *get_qf_name(int type, int fmt, char *buf)
-{
-	BUG_ON(!buf);
-	snprintf(buf, PATH_MAX, "%s.%s",
-		 basenames[fmt], extensions[type]);
-
-	return buf;
-}
-
 /*
  * Set grace time if needed
  */
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index e2fdb4a..88e814b 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -710,7 +710,7 @@ void handle_quota_options(ext2_filsys fs)
 	init_quota_context(&qctx, fs, -1);
 
 	if (usrquota == QOPT_ENABLE && !fs->super->s_usr_quota_inum) {
-		if ((qf_ino = quota_file_exists(fs, USRQUOTA, QFMT_VFS_V1)) > 0)
+		if ((qf_ino = quota_file_exists(fs, USRQUOTA)) > 0)
 			set_sb_quota_inum(fs, qf_ino, USRQUOTA);
 		else
 			write_quota_inode(qctx, USRQUOTA);
@@ -719,7 +719,7 @@ void handle_quota_options(ext2_filsys fs)
 	}
 
 	if (grpquota == QOPT_ENABLE && !fs->super->s_grp_quota_inum) {
-		if ((qf_ino = quota_file_exists(fs, GRPQUOTA, QFMT_VFS_V1)) > 0)
+		if ((qf_ino = quota_file_exists(fs, GRPQUOTA)) > 0)
 			set_sb_quota_inum(fs, qf_ino, GRPQUOTA);
 		else
 			write_quota_inode(qctx, GRPQUOTA);
-- 
1.7.4.1.22.gec8e1.dirty


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/5] libquota: use ext2_loff_t instead of loff_t
  2011-10-04 16:16 [PATCH 1/5] libquota: remove get_qf_path() Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 2/5] libquota: clean up some gcc -Wall warnings Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 3/5] libquota: remove get_qf_name() Theodore Ts'o
@ 2011-10-04 16:16 ` Theodore Ts'o
  2011-10-04 16:16 ` [PATCH 5/5] libquota: remove NLS support Theodore Ts'o
  3 siblings, 0 replies; 6+ messages in thread
From: Theodore Ts'o @ 2011-10-04 16:16 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Aditya Kali, Theodore Ts'o

The type loff_t is not portable.  Use ext2_loff_t which handles this
for us.

Cc: Aditya Kali <adityakali@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/quota/quotaio.c      |    8 +++++---
 lib/quota/quotaio.h      |    4 ++--
 lib/quota/quotaio_tree.c |   16 +++++++++-------
 3 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/lib/quota/quotaio.c b/lib/quota/quotaio.c
index f651353..0457886 100644
--- a/lib/quota/quotaio.c
+++ b/lib/quota/quotaio.c
@@ -133,7 +133,8 @@ static ext2_off64_t compute_inode_size(ext2_filsys fs, ext2_ino_t ino)
 }
 
 /* Functions to read/write quota file. */
-static unsigned int quota_write_nomount(struct quota_file *qf, loff_t offset,
+static unsigned int quota_write_nomount(struct quota_file *qf,
+					ext2_loff_t offset,
 					void *buf, unsigned int size)
 {
 	ext2_file_t	e2_file = qf->e2_file;
@@ -156,8 +157,9 @@ static unsigned int quota_write_nomount(struct quota_file *qf, loff_t offset,
 	return bytes_written;
 }
 
-static unsigned int quota_read_nomount(struct quota_file *qf, loff_t offset,
-					void *buf, unsigned int size)
+static unsigned int quota_read_nomount(struct quota_file *qf,
+				       ext2_loff_t offset,
+				       void *buf, unsigned int size)
 {
 	ext2_file_t	e2_file = qf->e2_file;
 	unsigned int	bytes_read = 0;
diff --git a/lib/quota/quotaio.h b/lib/quota/quotaio.h
index f2c34f2..333a59f 100644
--- a/lib/quota/quotaio.h
+++ b/lib/quota/quotaio.h
@@ -56,9 +56,9 @@ struct quota_handle {
 	int qh_fmt;		/* Quotafile format */
 	int qh_io_flags;	/* IO flags for file */
 	struct quota_file qh_qf;
-	unsigned int (*e2fs_read)(struct quota_file *qf, loff_t offset,
+	unsigned int (*e2fs_read)(struct quota_file *qf, ext2_loff_t offset,
 			 void *buf, unsigned int size);
-	unsigned int (*e2fs_write)(struct quota_file *qf, loff_t offset,
+	unsigned int (*e2fs_write)(struct quota_file *qf, ext2_loff_t offset,
 			  void *buf, unsigned int size);
 	struct quotafile_ops *qh_ops;	/* Operations on quotafile */
 	struct util_dqinfo qh_info;	/* Generic quotafile info */
diff --git a/lib/quota/quotaio_tree.c b/lib/quota/quotaio_tree.c
index 1daea75..0890ca3 100644
--- a/lib/quota/quotaio_tree.c
+++ b/lib/quota/quotaio_tree.c
@@ -392,8 +392,8 @@ void qtree_delete_dquot(struct dquot *dquot)
 }
 
 /* Find entry in block */
-static loff_t find_block_dqentry(struct quota_handle *h,
-				 struct dquot *dquot, uint blk)
+static ext2_loff_t find_block_dqentry(struct quota_handle *h,
+				      struct dquot *dquot, uint blk)
 {
 	struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
 	dqbuf_t buf = getdqbuf();
@@ -415,11 +415,12 @@ static loff_t find_block_dqentry(struct quota_handle *h,
 }
 
 /* Find entry for given id in the tree */
-static loff_t find_tree_dqentry(struct quota_handle *h, struct dquot *dquot,
-				uint blk, int depth)
+static ext2_loff_t find_tree_dqentry(struct quota_handle *h,
+				     struct dquot *dquot,
+				     uint blk, int depth)
 {
 	dqbuf_t buf = getdqbuf();
-	loff_t ret = 0;
+	ext2_loff_t ret = 0;
 	u_int32_t *ref = (u_int32_t *) buf;
 
 	read_blk(h, blk, buf);
@@ -437,7 +438,8 @@ out_buf:
 }
 
 /* Find entry for given id in the tree - wrapper function */
-static inline loff_t find_dqentry(struct quota_handle *h, struct dquot *dquot)
+static inline ext2_loff_t find_dqentry(struct quota_handle *h,
+				       struct dquot *dquot)
 {
 	return find_tree_dqentry(h, dquot, QT_TREEOFF, 0);
 }
@@ -449,7 +451,7 @@ static inline loff_t find_dqentry(struct quota_handle *h, struct dquot *dquot)
 struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id)
 {
 	struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree;
-	loff_t offset;
+	ext2_loff_t offset;
 	ssize_t ret;
 	char *ddquot = smalloc(info->dqi_entry_size);
 	struct dquot *dquot = get_empty_dquot();
-- 
1.7.4.1.22.gec8e1.dirty


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/5] libquota: remove NLS support
  2011-10-04 16:16 [PATCH 1/5] libquota: remove get_qf_path() Theodore Ts'o
                   ` (2 preceding siblings ...)
  2011-10-04 16:16 ` [PATCH 4/5] libquota: use ext2_loff_t instead of loff_t Theodore Ts'o
@ 2011-10-04 16:16 ` Theodore Ts'o
  2011-10-04 16:24   ` Aditya Kali
  3 siblings, 1 reply; 6+ messages in thread
From: Theodore Ts'o @ 2011-10-04 16:16 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Aditya Kali, Theodore Ts'o

In general libraries should never (a) call exit() or (b) print output
directly to the stdout (they might be used by GUI programs.  From (b)
follows (c), should never call internationalization functions
directly.

Also, since po/POTFILES.in wasn't edited, these strings weren't
getting included in e2fsprogs.pot for translation, so the _()
indirection didn't actually buy us anything.

We eventually need to nuke all of the log_fatal() and log_err() from
libquota, so best thing to do for now is remove NLS support
completely; no point whipsawing the translators with strings to
translate that will be disappearing soon anyway!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/quota/common.h |   30 ++++--------------------------
 1 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/lib/quota/common.h b/lib/quota/common.h
index 48f191f..7b88003 100644
--- a/lib/quota/common.h
+++ b/lib/quota/common.h
@@ -13,41 +13,19 @@
 # endif
 #endif
 
-#ifdef ENABLE_NLS
-#include <libintl.h>
-#include <locale.h>
-#define _(a) (gettext (a))
-#ifdef gettext_noop
-#define N_(a) gettext_noop (a)
-#else
-#define N_(a) (a)
-#endif
-#define P_(singular, plural, n) (ngettext (singular, plural, n))
-#ifndef NLS_CAT_NAME
-#define NLS_CAT_NAME "e2fsprogs"
-#endif
-#ifndef LOCALEDIR
-#define LOCALEDIR "/usr/share/locale"
-#endif
-#else
-#define _(a) (a)
-#define N_(a) a
-#define P_(singular, plural, n) ((n) == 1 ? (singular) : (plural))
-#endif
-
 #define log_fatal(exit_code, format, ...)	do { \
-		fprintf(stderr, _("[FATAL] %s:%d:%s:: " format "\n"), \
+		fprintf(stderr, "[FATAL] %s:%d:%s:: " format "\n", \
 			__FILE__, __LINE__, __func__, __VA_ARGS__); \
 		exit(exit_code); \
 	} while (0)
 
 #define log_err(format, ...)	fprintf(stderr, \
-				_("[ERROR] %s:%d:%s:: " format "\n"), \
+				"[ERROR] %s:%d:%s:: " format "\n", \
 				__FILE__, __LINE__, __func__, __VA_ARGS__)
 
 #ifdef DEBUG_QUOTA
 # define log_debug(format, ...)	fprintf(stderr, \
-				_("[DEBUG] %s:%d:%s:: " format "\n"), \
+				"[DEBUG] %s:%d:%s:: " format "\n", \
 				__FILE__, __LINE__, __func__, __VA_ARGS__)
 #else
 # define log_debug(format, ...)
@@ -55,7 +33,7 @@
 
 #define BUG_ON(x)		do { if ((x)) { \
 					fprintf(stderr, \
-						_("BUG_ON: %s:%d:: ##x"), \
+						"BUG_ON: %s:%d:: ##x", \
 						__FILE__, __LINE__); \
 					exit(2); \
 				} } while (0)
-- 
1.7.4.1.22.gec8e1.dirty


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 5/5] libquota: remove NLS support
  2011-10-04 16:16 ` [PATCH 5/5] libquota: remove NLS support Theodore Ts'o
@ 2011-10-04 16:24   ` Aditya Kali
  0 siblings, 0 replies; 6+ messages in thread
From: Aditya Kali @ 2011-10-04 16:24 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: Ext4 Developers List

Hi Ted,

Thanks for the patches.
I do have patches that removes log_err() and log_fatal() and all
'exit()' calls (and bunch of other cleanups). I will send those
patches as soon as possible.

Thanks,

On Tue, Oct 4, 2011 at 9:16 AM, Theodore Ts'o <tytso@mit.edu> wrote:
>
> In general libraries should never (a) call exit() or (b) print output
> directly to the stdout (they might be used by GUI programs.  From (b)
> follows (c), should never call internationalization functions
> directly.
>
> Also, since po/POTFILES.in wasn't edited, these strings weren't
> getting included in e2fsprogs.pot for translation, so the _()
> indirection didn't actually buy us anything.
>
> We eventually need to nuke all of the log_fatal() and log_err() from
> libquota, so best thing to do for now is remove NLS support
> completely; no point whipsawing the translators with strings to
> translate that will be disappearing soon anyway!
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  lib/quota/common.h |   30 ++++--------------------------
>  1 files changed, 4 insertions(+), 26 deletions(-)
>
> diff --git a/lib/quota/common.h b/lib/quota/common.h
> index 48f191f..7b88003 100644
> --- a/lib/quota/common.h
> +++ b/lib/quota/common.h
> @@ -13,41 +13,19 @@
>  # endif
>  #endif
>
> -#ifdef ENABLE_NLS
> -#include <libintl.h>
> -#include <locale.h>
> -#define _(a) (gettext (a))
> -#ifdef gettext_noop
> -#define N_(a) gettext_noop (a)
> -#else
> -#define N_(a) (a)
> -#endif
> -#define P_(singular, plural, n) (ngettext (singular, plural, n))
> -#ifndef NLS_CAT_NAME
> -#define NLS_CAT_NAME "e2fsprogs"
> -#endif
> -#ifndef LOCALEDIR
> -#define LOCALEDIR "/usr/share/locale"
> -#endif
> -#else
> -#define _(a) (a)
> -#define N_(a) a
> -#define P_(singular, plural, n) ((n) == 1 ? (singular) : (plural))
> -#endif
> -
>  #define log_fatal(exit_code, format, ...)      do { \
> -               fprintf(stderr, _("[FATAL] %s:%d:%s:: " format "\n"), \
> +               fprintf(stderr, "[FATAL] %s:%d:%s:: " format "\n", \
>                        __FILE__, __LINE__, __func__, __VA_ARGS__); \
>                exit(exit_code); \
>        } while (0)
>
>  #define log_err(format, ...)   fprintf(stderr, \
> -                               _("[ERROR] %s:%d:%s:: " format "\n"), \
> +                               "[ERROR] %s:%d:%s:: " format "\n", \
>                                __FILE__, __LINE__, __func__, __VA_ARGS__)
>
>  #ifdef DEBUG_QUOTA
>  # define log_debug(format, ...)        fprintf(stderr, \
> -                               _("[DEBUG] %s:%d:%s:: " format "\n"), \
> +                               "[DEBUG] %s:%d:%s:: " format "\n", \
>                                __FILE__, __LINE__, __func__, __VA_ARGS__)
>  #else
>  # define log_debug(format, ...)
> @@ -55,7 +33,7 @@
>
>  #define BUG_ON(x)              do { if ((x)) { \
>                                        fprintf(stderr, \
> -                                               _("BUG_ON: %s:%d:: ##x"), \
> +                                               "BUG_ON: %s:%d:: ##x", \
>                                                __FILE__, __LINE__); \
>                                        exit(2); \
>                                } } while (0)
> --
> 1.7.4.1.22.gec8e1.dirty
>



--
Aditya
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-10-04 16:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-04 16:16 [PATCH 1/5] libquota: remove get_qf_path() Theodore Ts'o
2011-10-04 16:16 ` [PATCH 2/5] libquota: clean up some gcc -Wall warnings Theodore Ts'o
2011-10-04 16:16 ` [PATCH 3/5] libquota: remove get_qf_name() Theodore Ts'o
2011-10-04 16:16 ` [PATCH 4/5] libquota: use ext2_loff_t instead of loff_t Theodore Ts'o
2011-10-04 16:16 ` [PATCH 5/5] libquota: remove NLS support Theodore Ts'o
2011-10-04 16:24   ` Aditya Kali

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.