olli at lurza.secnetix.de
Fri Dec 15 01:31:40 PST 2006
Olivier Mueller wrote:
> Le 15 déc. 06 à 00:57, Oliver Fromme a écrit :
> > Olivier Mueller wrote:
> > > I'm trying to get a script working with the p5-Quota module, but no
> > > way... :
> > > - quota correctely working for the /home partition
> > > - tested with edquota/repquota, etc.
> > >
> > > But when trying to retrieve information or setup quota information
> > > from
> > > a perl script, I get: Quota::sync: error #45
> > I guess that's an errno number, and in that case 45 is
> > EOPNOTSUPP (Operation not supported). It is a bug that
> > the errno number is not printed as a human-readable
> > string.
> > Did you try to use Quota::query? Does it work?
> Tried yes, work: no.
Which means, exactly? Same error message?
Are you sure that you specify the file system correctly?
Is your kernel compiled with "options QUOTA"?
> > > But what bothers me more is that exactely the same script (with the
> > > same module) is working fine under linux...
> > According to the p5-Quota documentation, the Quota::sync
> > function is not supported on all platforms, so it's
> > perfectly possible that the p5-Quota code supports it
> > on Linux, but not on FreeBSD.
> Well, in this case, why would there be a freebsd port for this
> module? :-)
The sync function is optional and not necessarily required
for the rest of the module to be useful. (Although it
_should_ work on FreeBSD.)
Of course, if the query function doesn't work either, then
there really is something wrong.
> I'll continue my tests... And if it doesn't work, I'll simply use the
> system commands
That's how I do it in a Python program. Since I'm not
querying quotas ten times per second or so, calling the
system commands isn't really a problem.
> instead of the perl module, but then I would have to rewrite some
> part of my scripts.
Well, should be just three or four lines. In my Python
program I'm doing it's the following code (this won't help
you, I'm afraid, but I'm quoting it so someone who searches
the archives might find it helpful):
quotas = dict([
for line in getoutput("repquota -a /home").splitlines()[2:]
for user, qinfo in [line.split(None,1)]
That creates a dictionary (Perl calls it a "hash") with
the user names as keys and their quota information as
values (a list with 9 string elements, corresponding to
the columns in repquota output). E.g. quotas["joe"]
will give the soft blocks limit of user joe. If quotas
are disabled, the dictionary is empty, so you can
simply write "if quotas: ..." or "if not quotas: ..."
to check whether quotas are enabled at all.
I'm sure you can do it similarly in Perl.
Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.
"I made up the term 'object-oriented', and I can tell you
I didn't have C++ in mind."
-- Alan Kay, OOPSLA '97
More information about the freebsd-stable