4 # * Quota management support.
6 # * Copyright 2005 (c) Sogeti-Transiciel Technologies
8 # * @author Olivier Fourdan ofourdan@mail.transiciel.com
11 # * This file is released under the GNU GPL license.
18 my $source_path = `forge_get_config source_path`;
21 require ("$source_path/lib/include.pl") ; # Include all the predefined functions
23 my $BLOCK_SIZE=$ENV{'BLOCK_SIZE'} || 1024;
27 my ($gid, $group_name, $quota_soft, $quota_hard) = @_;
28 my $dev = Quota::getqcarg ($grpdir_prefix);
29 my ($bc,$bs,$bh,$bt, $ic,$is,$ih,$it) = Quota::query ($dev, $gid, 1);
31 print "Setting Quota for group \"$group_name\" ($gid) on device \"$dev\":\n";
32 printf " - Current usage is %i blocks (%.2f Mb).\n", $bc, $bc / $BLOCK_SIZE;
33 print " - Current limits: $bs blocks soft, $bh blocks hard.\n";
34 Quota::setqlim ($dev, $gid, $quota_soft, $quota_hard, 0, 0, 0, 1);
36 ($bc,$bs,$bh,$bt, $ic,$is,$ih,$it) = Quota::query ($dev, $gid, 1);
37 print " - New limits: $bs blocks soft, $bh blocks hard.\n";
42 $sql = "SELECT unix_group_name, quota_soft, quota_hard FROM groups";
43 $res = $dbh->prepare($sql);
46 while ( my ($group, $quota_soft, $quota_hard) = $res->fetchrow())
48 my $scm_group = "scm_" . $group ;
49 my $gid = getgrnam($group);
52 &set_quota ($gid, $group, $quota_soft, $quota_hard);
55 # Also set limits for the scm group, as it's a different one....
56 $gid = getgrnam($scm_group);
59 &set_quota ($gid, $scm_group, $quota_soft, $quota_hard);