* [PATCH] Fix "quota -n" command in xfs_quota. @ 2007-04-19 8:37 Utako Kusaka 2007-04-23 21:26 ` Christoph Hellwig 0 siblings, 1 reply; 3+ messages in thread From: Utako Kusaka @ 2007-04-19 8:37 UTC (permalink / raw) To: xfs Hi, "quota -n" command in xfs_quota don't work when specifying the project id. This patch fixes it. Example: # ./xfs_quota -x -c 'quota -p -n 42' ~utako/mpnt Disk quotas for Project logfiles (42) Filesystem Blocks Quota Limit Warn/Time Mounted on /dev/sda6 52 0 0 00 [--------] /home/utako/mpnt Signed-off-by: Utako Kusaka <utako@tnes.nec.co.jp> --- --- xfsprogs-2.8.20/quota/quota.orig 2007-04-18 10:36:38.000000000 +0900 +++ xfsprogs-2.8.20/quota/quota.c 2007-04-18 11:09:10.000000000 +0900 @@ -312,7 +312,7 @@ getprojectname( static char buffer[32]; fs_project_t *p; - if ((p = getprprid(prid))) + if (!numeric && (p = getprprid(prid))) return p->pr_name; snprintf(buffer, sizeof(buffer), "#%u", (unsigned int)prid); return &buffer[0]; ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix "quota -n" command in xfs_quota. 2007-04-19 8:37 [PATCH] Fix "quota -n" command in xfs_quota Utako Kusaka @ 2007-04-23 21:26 ` Christoph Hellwig 2007-04-24 6:10 ` Utako Kusaka 0 siblings, 1 reply; 3+ messages in thread From: Christoph Hellwig @ 2007-04-23 21:26 UTC (permalink / raw) To: Utako Kusaka; +Cc: xfs On Thu, Apr 19, 2007 at 05:37:11PM +0900, Utako Kusaka wrote: > Hi, > > "quota -n" command in xfs_quota don't work when specifying the project id. > This patch fixes it. > > Example: > # ./xfs_quota -x -c 'quota -p -n 42' ~utako/mpnt > Disk quotas for Project logfiles (42) > Filesystem Blocks Quota Limit Warn/Time Mounted on > /dev/sda6 52 0 0 00 [--------] /home/utako/mpnt Looks good to me, but the even the original code could be a little bit cleaner: > --- xfsprogs-2.8.20/quota/quota.orig 2007-04-18 10:36:38.000000000 +0900 > +++ xfsprogs-2.8.20/quota/quota.c 2007-04-18 11:09:10.000000000 +0900 > @@ -312,7 +312,7 @@ getprojectname( > static char buffer[32]; > fs_project_t *p; > > - if ((p = getprprid(prid))) > + if (!numeric && (p = getprprid(prid))) > return p->pr_name; > snprintf(buffer, sizeof(buffer), "#%u", (unsigned int)prid); > return &buffer[0]; if (!numeric) { fs_project_t *p = getprprid(prid); if (p) return p->pr_name; } snprintf(buffer, sizeof(buffer), "#%u", (unsigned int)prid); return &buffer[0]; ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Fix "quota -n" command in xfs_quota. 2007-04-23 21:26 ` Christoph Hellwig @ 2007-04-24 6:10 ` Utako Kusaka 0 siblings, 0 replies; 3+ messages in thread From: Utako Kusaka @ 2007-04-24 6:10 UTC (permalink / raw) To: Christoph Hellwig; +Cc: xfs Hi, Thanks for your comment. I have updated my patch as below. Signed-off-by: Utako Kusaka <utako@tnes.nec.co.jp> --- --- quota.orig 2007-04-18 10:36:38.000000000 +0900 +++ quota.c 2007-04-24 11:42:18.000000000 +0900 @@ -202,10 +202,12 @@ getusername( int numeric) { static char buffer[32]; - struct passwd *u; - if (!numeric && (u = getpwuid(uid))) - return u->pw_name; + if (!numeric) { + struct passwd *u = getpwuid(uid); + if (u) + return u->pw_name; + } snprintf(buffer, sizeof(buffer), "#%u", uid); return &buffer[0]; } @@ -247,10 +249,12 @@ getgroupname( int numeric) { static char buffer[32]; - struct group *g; - if (!numeric && (g = getgrgid(gid))) - return g->gr_name; + if (!numeric) { + struct group *g = getgrgid(gid); + if (g) + return g->gr_name; + } snprintf(buffer, sizeof(buffer), "#%u", gid); return &buffer[0]; } @@ -310,10 +314,12 @@ getprojectname( int numeric) { static char buffer[32]; - fs_project_t *p; - if ((p = getprprid(prid))) - return p->pr_name; + if (!numeric) { + fs_project_t *p = getprprid(prid); + if (p) + return p->pr_name; + } snprintf(buffer, sizeof(buffer), "#%u", (unsigned int)prid); return &buffer[0]; } Mon, 23 Apr 2007 22:26:06 +0100 Christoph Hellwig wrote: > >Looks good to me, but the even the original code could be a little bit cleaner: > >> --- xfsprogs-2.8.20/quota/quota.orig 2007-04-18 10:36:38.000000000 +0900 >> +++ xfsprogs-2.8.20/quota/quota.c 2007-04-18 11:09:10.000000000 +0900 >> @@ -312,7 +312,7 @@ getprojectname( >> static char buffer[32]; >> fs_project_t *p; >> >> - if ((p = getprprid(prid))) >> + if (!numeric && (p = getprprid(prid))) >> return p->pr_name; >> snprintf(buffer, sizeof(buffer), "#%u", (unsigned int)prid); >> return &buffer[0]; > > if (!numeric) { > fs_project_t *p = getprprid(prid); > if (p) > return p->pr_name; > } > > snprintf(buffer, sizeof(buffer), "#%u", (unsigned int)prid); > return &buffer[0]; > > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-24 6:18 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-04-19 8:37 [PATCH] Fix "quota -n" command in xfs_quota Utako Kusaka 2007-04-23 21:26 ` Christoph Hellwig 2007-04-24 6:10 ` Utako Kusaka
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox