- sq = sq_create();
-## repeat retrieve (dev = trim(n.#device))
-## where n.mach_id = m.mach_id and m.name = @machname {
- sq_save_data(sq, strsave(dev));
-## }
- while (sq_get_data(sq, &device)) {
-## repeat retrieve (id = n.nfsphys_id) where n.mach_id = m.mach_id and
-## m.#name = @machname and n.#device = @device
- while (cp = index(device, '/')) *cp = '@';
- sprintf(file, "%s/%s.%s.quotas", NFS_DIR, machname, device);
- fd = fopen(file, "w");
- if (!fd) {
- fprintf(stderr, "cannot open %s for output\n", file);
- exit(SMS_OCONFIG);
- }
- prevuid = -1;
- quotasum = 0;
-## repeat retrieve (uid = u.#uid, quota = q.#quota)
-## where q.users_id = u.users_id and q.filsys_id = f.filsys_id and
-## f.phys_id = @id and u.status != 0 sort by #uid {
- if (uid != prevuid) {
- if (quotasum)
- fprintf(fd, "%d %d\n", prevuid, quotasum);
- prevuid = uid;
- quotasum = quota;
- } else {
- quotasum += quota;
- }
-## }
- if (quotasum)
- fprintf(fd, "%d %d\n", prevuid, quotasum);
- if (fclose(fd)) {
- fprintf(stderr, "error closing %s", file);
- exit(SMS_CCONFIG);
- }
- sprintf(file, "%s/%s.%s.dirs", NFS_DIR, machname, device);
- fd = fopen(file, "w");
- if (!fd) {
- fprintf(stderr, "cannot open %s for output\n", file);
- exit(SMS_OCONFIG);
- }
-## repeat retrieve (dir = trim(f.#name), fstype = trim(f.lockertype),
-## uid = u.#uid, gid = l.#gid)
-## where f.phys_id = @id and f.owner = u.users_id and
-## f.owners = l.list_id and f.createflg != 0 {
- fprintf(fd, "%s %d %d %s\n", dir, uid, gid, fstype);
-## }
- if (fclose(fd)) {
- fprintf(stderr, "error closing %s", file);
- exit(SMS_CCONFIG);
- }
- }
- sq_destroy(sq);
+ hash_store(machines, id, machname);
+ }
+
+ olddev = oldmach = -1;
+ fd = stdin;
+## retrieve (quota = q.#quota, uid = u.#uid, flag1 = q.phys_id,
+## dev = n.device, flag2 = n.mach_id)
+## where u.users_id = q.entity_id and n.nfsphys_id = q.phys_id and
+## q.phys_id != 0 and n.status < 16 and q.type = "USER"
+## sort by #flag2, #flag1, #uid {
+ if (flag1 != olddev || flag2 != oldmach) {
+ fclose(fd);
+ olddev = flag1;
+ oldmach = flag2;
+ while (cp = index(dev, '/')) *cp = '@';
+ sprintf(file, "%s/%s.%s.quotas", nfs_dir,
+ hash_lookup(machines, flag2), strtrim(dev));
+ fd = fopen(file, "w");
+ if (!fd) {
+ fprintf(stderr, "cannot open %s for output\n", file);
+ exit(MR_OCONFIG);
+ }
+ prevuid = -1;
+ quotasum = 0;
+ }
+ if (uid != prevuid) {
+ if (quotasum)
+ fprintf(fd, "%d %d\n", prevuid, quotasum);
+ prevuid = uid;
+ quotasum = quota;
+ } else {
+ quotasum += quota;
+ }
+## }
+ if (quotasum)
+ fprintf(fd, "%d %d\n", prevuid, quotasum);
+ if (fd != stdin && fclose(fd)) {
+ fprintf(stderr, "error closing %s", file);
+ exit(MR_CCONFIG);
+ }
+
+ olddev = oldmach = -1;
+ fd = stdin;
+## retrieve (quota = q.#quota, gid = l.#gid, flag1 = q.phys_id,
+## dev = n.device, flag2 = n.mach_id, flag3 = n.status)
+## where l.list_id = q.entity_id and n.nfsphys_id = q.phys_id and
+## q.phys_id != 0 and n.status > 15 and q.type = "GROUP"
+## sort by #flag2, #flag1, #gid {
+ if (flag1 != olddev || flag2 != oldmach) {
+ fclose(fd);
+ olddev = flag1;
+ oldmach = flag2;
+ while (cp = index(dev, '/')) *cp = '@';
+ sprintf(file, "%s/%s.%s.quotas", nfs_dir,
+ hash_lookup(machines, flag2), strtrim(dev));
+ fd = fopen(file, "w");
+ if (!fd) {
+ fprintf(stderr, "cannot open %s for output\n", file);
+ exit(MR_OCONFIG);
+ }
+ prevuid = -1;
+ quotasum = 0;
+ }
+ if (gid != prevuid) {
+ if (quotasum)
+ fprintf(fd, "%d %d\n", prevuid, quotasum);
+ prevuid = gid;
+ quotasum = quota;
+ } else {
+ quotasum += quota;
+ }
+## }
+ if (quotasum)
+ fprintf(fd, "%d %d\n", prevuid, quotasum);
+ if (fd != stdin && fclose(fd)) {
+ fprintf(stderr, "error closing %s", file);
+ exit(MR_CCONFIG);
+ }
+
+ olddev = oldmach = -1;
+## retrieve (dir = f.#name, fstype = f.lockertype, uid = u.#uid,
+## gid = l.#gid, flag1 = f.phys_id, flag2 = f.mach_id,
+## dev = n.device)
+## where u.users_id = f.owner and l.list_id = f.owners and
+## f.createflg != 0 and f.phys_id != 0 and f.type = "NFS" and
+## f.phys_id = n.nfsphys_id
+## sort by #flag2, #flag1 {
+ if (flag1 != olddev || flag2 != oldmach) {
+ fclose(fd);
+ olddev = flag1;
+ oldmach = flag2;
+ while (cp = index(dev, '/')) *cp = '@';
+ sprintf(file, "%s/%s.%s.dirs", nfs_dir,
+ hash_lookup(machines, flag2), strtrim(dev));
+ fd = fopen(file, "w");
+ if (!fd) {
+ fprintf(stderr, "cannot open %s for output\n", file);
+ exit(MR_OCONFIG);
+ }
+ }
+ fprintf(fd, "%s %d %d %s\n", strtrim(dir), uid, gid, strtrim(fstype));
+## }
+ if (fclose(fd)) {
+ fprintf(stderr, "error closing %s", file);
+ exit(MR_CCONFIG);