File: test-group.pl

package info (click to toggle)
libquota-perl 1.7.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 360 kB
  • sloc: ansic: 975; perl: 793; sh: 51; makefile: 9
file content (56 lines) | stat: -rwxr-xr-x 1,601 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl
#
# testing group quota support  -tom Apr/02/1999
#
# This script is in the public domain and can be used and redistributed
# without restrictions.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

use blib;
use Quota;

##
## insert your test case constants here:
##
$path  = ".";
$ugid  = 2001;
$dogrp = 1;
@setq  = qw(123 124 51 52);


$typnam = ($dogrp ? "group" : "user");
$dev = Quota::getqcarg($path);
die "$path: mount point not found\n" unless $dev;
print "Using device/argument \"$dev\"\n";

if(Quota::sync($dev) && ($! != 1)) {
    die "Quota::sync: ".Quota::strerr."\n";
}

print "\nQuery this fs with $typnam id $ugid\n";
($bc,$bs,$bh,$bt,$fc,$fs,$fh,$ft) = Quota::query($dev,$ugid,$dogrp);
if(defined($bc)) {
  my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($bt);
  $bt = sprintf("%04d-%02d-%02d/%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min) if $bt;
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($ft);
  $ft = sprintf("%04d-%02d-%02d/%02d:%02d", $year+1900,$mon+1,$mday,$hour,$min) if $ft;

  print "$typnam usage and limits are $bc ($bs,$bh,$bt) $fc ($fs,$fh,$ft)\n\n";
}
else {
  die "Quota::query($dev,$ugid,$dogrp): ",Quota::strerr,"\n";
}

##
##  set quota block & file limits for user
##

Quota::setqlim($dev, $ugid, @setq, 1, $dogrp) && die Quota::strerr,"\n";
print "$typnam quotas set for id $ugid\n";

Quota::sync($dev) && ($! != 1) && die "Quota::sync: ".Quota::strerr."\n";