* [RFC] [PATCH] xfs_quota: support relative path as `path' arguments
@ 2012-11-27 10:05 Satoru Takeuchi
2012-11-27 16:50 ` Carlos Maiolino
0 siblings, 1 reply; 3+ messages in thread
From: Satoru Takeuchi @ 2012-11-27 10:05 UTC (permalink / raw)
To: xfs ML
From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Current xfs_quota only accepts absolute path as its `path' arguments.
This patch adds the support of relative path for user's convenience.
Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
---
libxcmd/paths.c | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/libxcmd/paths.c b/libxcmd/paths.c
index 2a92299..bd84cde 100644
--- a/libxcmd/paths.c
+++ b/libxcmd/paths.c
@@ -27,6 +27,7 @@
#include <xfs/path.h>
#include <xfs/input.h>
#include <xfs/project.h>
+#include <limits.h>
extern char *progname;
@@ -273,6 +274,7 @@ fs_table_initialise_mounts(
FILE *mtp;
char *fslog, *fsrt;
int error, found;
+ char *rpath = NULL;
error = found = 0;
fslog = fsrt = NULL;
@@ -286,26 +288,32 @@ fs_table_initialise_mounts(
if ((mtp = setmntent(mtab_file, "r")) == NULL)
return ENOENT;
+ if (path)
+ if ((rpath = realpath(path, NULL)) == NULL)
+ return ENOENT;
+
while ((mnt = getmntent(mtp)) != NULL) {
if (strcmp(mnt->mnt_type, "xfs") != 0)
continue;
- if (path &&
- ((strcmp(path, mnt->mnt_dir) != 0) &&
- (strcmp(path, mnt->mnt_fsname) != 0)))
+ if (rpath &&
+ ((strcmp(rpath, mnt->mnt_dir) != 0) &&
+ (strcmp(rpath, mnt->mnt_fsname) != 0)))
continue;
if (fs_extract_mount_options(mnt, &fslog, &fsrt))
continue;
(void) fs_table_insert(mnt->mnt_dir, 0, FS_MOUNT_POINT,
mnt->mnt_fsname, fslog, fsrt);
- if (path) {
+ if (rpath) {
found = 1;
break;
}
}
endmntent(mtp);
- if (path && !found)
- error = ENXIO;
-
+ if (rpath) {
+ free(rpath);
+ if (!found)
+ error = ENXIO;
+ }
return error;
}
@@ -318,6 +326,7 @@ fs_table_initialise_mounts(
{
struct statfs *stats;
int i, count, error, found;
+ char *rpath = NULL;
error = found = 0;
if ((count = getmntinfo(&stats, 0)) < 0) {
@@ -326,24 +335,31 @@ fs_table_initialise_mounts(
return 0;
}
+ if (path)
+ if ((rpath = realpath(path, NULL)) == NULL)
+ return ENOENT;
+
for (i = 0; i < count; i++) {
if (strcmp(stats[i].f_fstypename, "xfs") != 0)
continue;
- if (path &&
- ((strcmp(path, stats[i].f_mntonname) != 0) &&
- (strcmp(path, stats[i].f_mntfromname) != 0)))
+ if (rpath &&
+ ((strcmp(rpath, stats[i].f_mntonname) != 0) &&
+ (strcmp(rpath, stats[i].f_mntfromname) != 0)))
continue;
/* TODO: external log and realtime device? */
(void) fs_table_insert(stats[i].f_mntonname, 0,
FS_MOUNT_POINT, stats[i].f_mntfromname,
NULL, NULL);
- if (path) {
+ if (rpath) {
found = 1;
break;
}
}
- if (path && !found)
- error = ENXIO;
+ if (rpath) {
+ free(rpath);
+ if (!found)
+ error = ENXIO;
+ }
return error;
}
--
1.7.10.2
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC] [PATCH] xfs_quota: support relative path as `path' arguments
2012-11-27 10:05 [RFC] [PATCH] xfs_quota: support relative path as `path' arguments Satoru Takeuchi
@ 2012-11-27 16:50 ` Carlos Maiolino
2012-11-27 23:41 ` Satoru Takeuchi
0 siblings, 1 reply; 3+ messages in thread
From: Carlos Maiolino @ 2012-11-27 16:50 UTC (permalink / raw)
To: Satoru Takeuchi; +Cc: xfs ML
On Tue, Nov 27, 2012 at 07:05:40PM +0900, Satoru Takeuchi wrote:
> From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
>
> Current xfs_quota only accepts absolute path as its `path' arguments.
> This patch adds the support of relative path for user's convenience.
>
> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
>
Using realpath() to handle the path being passed by user, not only makes able
the usage of relative paths, but also fixes the problem in having a "/" at the
end of the path. For those who abuses of TABs, this is very annoying.
Looks good,
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Tested-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> libxcmd/paths.c | 42 +++++++++++++++++++++++++++++-------------
> 1 file changed, 29 insertions(+), 13 deletions(-)
>
> diff --git a/libxcmd/paths.c b/libxcmd/paths.c
> index 2a92299..bd84cde 100644
> --- a/libxcmd/paths.c
> +++ b/libxcmd/paths.c
> @@ -27,6 +27,7 @@
> #include <xfs/path.h>
> #include <xfs/input.h>
> #include <xfs/project.h>
> +#include <limits.h>
>
> extern char *progname;
>
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
--
Carlos
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] [PATCH] xfs_quota: support relative path as `path' arguments
2012-11-27 16:50 ` Carlos Maiolino
@ 2012-11-27 23:41 ` Satoru Takeuchi
0 siblings, 0 replies; 3+ messages in thread
From: Satoru Takeuchi @ 2012-11-27 23:41 UTC (permalink / raw)
To: Carlos Maiolino, xfs ML
Hi Carlos,
(2012/11/28 1:50), Carlos Maiolino wrote:
> On Tue, Nov 27, 2012 at 07:05:40PM +0900, Satoru Takeuchi wrote:
>
>> From: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
>>
>> Current xfs_quota only accepts absolute path as its `path' arguments.
>> This patch adds the support of relative path for user's convenience.
>>
>> Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
>>
>
> Using realpath() to handle the path being passed by user, not only makes able
> the usage of relative paths, but also fixes the problem in having a "/" at the
> end of the path. For those who abuses of TABs, this is very annoying.
Ah, I also tend to fix the trailing "/" at the end of the path as you said.
But I forgot to mentioned about it by the patch description :-)
Thanks,
Satoru
>
> Looks good,
>
> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> Tested-by: Carlos Maiolino <cmaiolino@redhat.com>
>
>> ---
>> libxcmd/paths.c | 42 +++++++++++++++++++++++++++++-------------
>> 1 file changed, 29 insertions(+), 13 deletions(-)
>>
>> diff --git a/libxcmd/paths.c b/libxcmd/paths.c
>> index 2a92299..bd84cde 100644
>> --- a/libxcmd/paths.c
>> +++ b/libxcmd/paths.c
>> @@ -27,6 +27,7 @@
>> #include <xfs/path.h>
>> #include <xfs/input.h>
>> #include <xfs/project.h>
>> +#include <limits.h>
>>
>> extern char *progname;
>>
>> xfs mailing list
>> xfs@oss.sgi.com
>> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-27 23:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 10:05 [RFC] [PATCH] xfs_quota: support relative path as `path' arguments Satoru Takeuchi
2012-11-27 16:50 ` Carlos Maiolino
2012-11-27 23:41 ` Satoru Takeuchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox