client *cl;
##{
## int nuid, rowcount;
+## char *mit_id;
+
+#ifdef notdef
+ /* this is currently disabled because we need an index on ID's
+ * before it can run in finite time.
+ */
+ mit_id = argv[U_MITID];
+## retrieve (rowcount = any(u.#mit_id where u.#mit_id = mit_id))
+ if (ingres_errno) return(mr_errcode);
+ if (rowcount) return(MR_EXISTS);
+#endif notdef
if (!strcmp(argv[1], UNIQUE_UID) || atoi(argv[1]) == -1) {
if (set_next_object_id("uid", "users"))
if (flag != 0 && flag != 4)
return(MR_IN_USE);
-## repeat delete nfsquota where nfsquota.users_id = @id
+## repeat delete quota where quota.entity_id = @id and quota.type = "USER"
## repeat delete krbmap where krbmap.users_id = @id
## repeat retrieve (flag = any(imembers.member_id where imembers.member_id=@id
## and imembers.member_type = "USER"))
## repeat retrieve (flag = any(printcap.mach_id where printcap.mach_id=@id))
if (flag)
return(MR_IN_USE);
+## repeat retrieve (flag = any(printcap.quotaserver where printcap.quotaserver=@id))
+ if (flag)
+ return(MR_IN_USE);
## repeat retrieve (flag = any(palladium.mach_id where palladium.mach_id=@id))
if (flag)
return(MR_IN_USE);
## servers.acl_type = "LIST"))
if (flag)
return(MR_IN_USE);
+## repeat retrieve (flag = any(quota.entity_id where quota.entity_id=@id and
+## quota.type = "GROUP"))
+ if (flag)
+ return(MR_IN_USE);
## repeat retrieve (flag=any(hostaccess.acl_id where hostaccess.acl_id=@id and
## hostaccess.acl_type = "LIST"))
if (flag)
setup_afil(q, argv)
struct query *q;
char *argv[];
-{
- char *type;
+##{
+ char *type, *name;
int mach_id;
- char *name;
- char *access;
+## int ok;
+## char ftype[32], *access;
type = argv[1];
mach_id = *(int *)argv[2];
access = argv[5];
var_phys_id = 0;
+ sprintf(ftype, "fs_access_%s", type);
+## retrieve (ok = any(alias.trans where alias.name = ftype and
+## alias.type = "TYPE" and alias.trans = access))
+ if (ingres_errno) return(mr_errcode);
+ if (ok == 0) return(MR_FILESYS_ACCESS);
+
if (!strcmp(type, "NFS"))
return (check_nfs(mach_id, name, access));
else
return(MR_SUCCESS);
-}
+##}
/* Verify the arguments, depending on the FStype. Also, if this is an
* the new phys_id.
*/
-setup_ufil(q, argv)
+setup_ufil(q, argv, cl)
struct query *q;
char *argv[];
+ client *cl;
##{
int mach_id, status;
- char *type, *name, *access;
-## int fid, total;
+ char *type, *name;
+## int fid, total, who;
+## char *entity, ftype[32], *access;
type = argv[2];
mach_id = *(int *)argv[3];
access = argv[6];
var_phys_id = 0;
fid = *(int *)argv[0];
+ who = cl->client_id;
+ entity = cl->entity;
+
+ sprintf(ftype, "fs_access_%s", type);
+## retrieve (total = any(alias.trans where alias.name = ftype and
+## alias.type = "TYPE" and alias.trans = access))
+ if (ingres_errno) return(mr_errcode);
+ if (total == 0) return(MR_FILESYS_ACCESS);
if (!strcmp(type, "NFS")) {
status = check_nfs(mach_id, name, access);
-## replace nfsquota (phys_id = var_phys_id) where nfsquota.filsys_id = fid
+## replace quota (phys_id = var_phys_id) where quota.filsys_id = fid
if (ingres_errno) return(mr_errcode);
return(status);
} else if (!strcmp(type, "AFS")) {
total = 0;
-## retrieve (total = sum(nfsquota.quota where nfsquota.filsys_id = fid))
+## retrieve (total = sum(quota.quota where quota.filsys_id = fid
+## and quota.phys_id != 0))
if (ingres_errno) return(mr_errcode);
if (total != 0) {
-## delete nfsquota where nfsquota.filsys_id = fid
- if (ingres_errno) return(mr_errcode);
-## append nfsquota (quota = total, filsys_id = fid,
-## phys_id = 0, users_id = 0)
+## append quota (quota = total, filsys_id = fid,
+## phys_id = 0, entity_id = 0, type = "ANY",
+## modtime = "now", modby = who, modwith = entity)
if (ingres_errno) return(mr_errcode);
}
} else {
-## replace nfsquota (phys_id = 0) where nfsquota.filsys_id = fid
+## replace quota (phys_id = 0) where quota.filsys_id = fid
if (ingres_errno) return(mr_errcode);
}
return(MR_SUCCESS);
register char *cp1;
register char *cp2;
- caccess = (isupper(*access)) ? tolower(*access) : *access;
- if (caccess != 'r' && caccess != 'w' && caccess != 'n')
- return(MR_FILESYS_ACCESS);
-
status = MR_NFS;
## range of np is nfsphys
## repeat retrieve (var_phys_id = np.#nfsphys_id, dir = trim(np.#dir))
## int id;
id = *(int *)argv[0];
-## range of q is nfsquota
+## range of q is quota
## range of n is nfsphys
## repeat replace n (allocated=n.allocated-sum(q.quota where q.filsys_id=@id))
## where n.nfsphys_id = filesys.phys_id and filesys.filsys_id = @id
##}
-/* setup_dnfq: Remove allocation from nfsphys before deleting quota.
+/* setup_dqot: Remove allocation from nfsphys before deleting quota.
* argv[0] = filsys_id
- * argv[1] = users_id
+ * argv[1] = type if "update_quota" or "delete_quota"
+ * argv[2 or 1] = users_id or list_id
*/
-setup_dnfq(q, argv, cl)
+setup_dqot(q, argv, cl)
struct query *q;
char **argv;
client *cl;
##{
-## int quota, fs, user;
+## int quota, fs, id;
+## char *qtype;
fs = *(int *)argv[0];
- user = *(int *)argv[1];
+ if (!strcmp(q->name, "update_quota") || !strcmp(q->name, "delete_quota")) {
+ qtype = argv[1];
+ id = *(int *)argv[2];
+ } else {
+ qtype = "USER";
+ id = *(int *)argv[1];
+ }
-## range of q is nfsquota
-## repeat retrieve (quota = q.#quota) where q.users_id = @user and
-## q.filsys_id = @fs
+## range of q is #quota
+## repeat retrieve (quota = q.#quota) where q.type = @qtype and
+## q.entity_id = @id and q.filsys_id = @fs
## repeat replace nfsphys (allocated = nfsphys.allocated - @quota)
## where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
if (ingres_errno) return(mr_errcode);
}
-/* followup_gnfq: Fix the directory name & modby fields
+/* followup_gqot: Fix the entity name, directory name & modby fields
* argv[0] = filsys_id
- * argv[2] = ascii(quota)
+ * argv[1] = type
+ * argv[2] = entity_id
+ * argv[3] = ascii(quota)
*/
-followup_gnfq(q, sq, v, action, actarg, cl)
+followup_gqot(q, sq, v, action, actarg, cl)
struct query *q;
register struct save_queue *sq;
struct validate *v;
char **argv, *malloc();
## int id, rowcount;
## char *name, *label;
- int status;
+ int status, idx;
+ if (!strcmp(q->name, "get_quota") ||
+ !strcmp(q->name, "get_quota_by_filesys"))
+ idx = 4;
+ else
+ idx = 3;
while (sq_get_data(sq, &argv)) {
- id = atoi(argv[3]);
- free(argv[3]);
- argv[3] = malloc(256);
- name = argv[3];
+ if (idx == 4) {
+ switch (argv[1][0]) {
+ case 'U':
+ status = id_to_name(atoi(argv[2]), "USER", &argv[2]);
+ break;
+ case 'G':
+ case 'L':
+ status = id_to_name(atoi(argv[2]), "LIST", &argv[2]);
+ break;
+ case 'A':
+ free(argv[2]);
+ argv[2] = strsave("system:anyuser");
+ break;
+ default:
+ id = atoi(argv[2]);
+ argv[2] = malloc(8);
+ sprintf(argv[2], "%d", id);
+ }
+ }
+ id = atoi(argv[idx]);
+ free(argv[idx]);
+ argv[idx] = malloc(256);
+ name = argv[idx];
if (id == 0) {
label = argv[0];
## repeat retrieve (name = filesys.#name) where filesys.#label = @label
}
## inquire_equel(rowcount = "rowcount")
if (rowcount != 1) {
- sprintf(argv[3], "#%d", id);
+ sprintf(argv[idx], "#%d", id);
}
- id = atoi(argv[6]);
+ id = atoi(argv[idx+3]);
if (id > 0)
- status = id_to_name(id, "USER", &argv[6]);
+ status = id_to_name(id, "USER", &argv[idx+3]);
else
- status = id_to_name(-id, "STRING", &argv[6]);
+ status = id_to_name(-id, "STRING", &argv[idx+3]);
if (status && status != MR_NO_MATCH)
return(status);
(*action)(q->vcnt, argv, actarg);
##}
-/* followup_anfq: Add allocation to nfsphys after creating quota.
+/* followup_aqot: Add allocation to nfsphys after creating quota.
* argv[0] = filsys_id
- * argv[2] = ascii(quota)
+ * argv[1] = type if "add_quota" or "update_quota"
+ * argv[2 or 1] = id
+ * argv[3 or 2] = ascii(quota)
*/
-followup_anfq(q, argv, cl)
+followup_aqot(q, argv, cl)
struct query *q;
char **argv;
client *cl;
##{
-## int quota, user, fs, who;
-## char *entity;
+## int quota, id, fs, who;
+## char *entity, *qtype;
fs = *(int *)argv[0];
- user = *(int *)argv[1];
- quota = atoi(argv[2]);
+ if (!strcmp(q->name, "add_quota") || !strcmp(q->name, "update_quota")) {
+ qtype = argv[1];
+ id = *(int *)argv[2];
+ quota = atoi(argv[3]);
+ } else {
+ qtype = "USER";
+ id = *(int *)argv[1];
+ quota = atoi(argv[2]);
+ }
who = cl->client_id;
entity = cl->entity;
-## repeat replace nq (modtime = "now", modby = @who, modwith = @entity)
-## where nq.filsys_id = @fs and nq.users_id = @user
+## repeat replace q (modtime = "now", modby = @who, modwith = @entity)
+## where q.filsys_id = @fs and q.type = @qtype and q.entity_id = @id
## repeat replace nfsphys (allocated = nfsphys.allocated + @quota)
## where nfsphys.nfsphys_id = filesys.#phys_id and filesys.filsys_id = @fs
if (ingres_errno) return(mr_errcode);
##}
+followup_gpce(q, sq, v, action, actarg, cl)
+ struct query *q;
+ register struct save_queue *sq;
+ struct validate *v;
+ register int (*action)();
+ register int actarg;
+ client *cl;
+{
+ register int i, j;
+ char **argv, *malloc();
+ int id, status;
+
+ i = q->vcnt - 2;
+ while (sq_get_data(sq, &argv)) {
+ id = atoi(argv[PCAP_QSERVER]);
+ status = id_to_name(id, "MACHINE", &argv[PCAP_QSERVER]);
+ if (status) return (status);
+ id = atoi(argv[i]);
+ if (id > 0)
+ status = id_to_name(id, "USER", &argv[i]);
+ else
+ status = id_to_name(-id, "STRING", &argv[i]);
+ if (status && status != MR_NO_MATCH)
+ return(status);
+ (*action)(q->vcnt, argv, actarg);
+ for (j = 0; j < q->vcnt; j++)
+ free(argv[j]);
+ free(argv);
+ }
+ sq_destroy(sq);
+ return(MR_SUCCESS);
+}
+
+
/* followup_gzcl:
*/
* how many different ancestors a member is allowed to have.
*/
-#define MAXLISTDEPTH 100
+#define MAXLISTDEPTH 1024
int add_member_to_list(q, argv, cl)
struct query *q;
/* find user */
## repeat retrieve (users_id = u.#users_id)
-## where u.#uid = @uid and (u.status = 0 or u.status = 5)
+## where u.#uid = @uid and (u.status = 0 or u.status = 5 or u.status = 6)
## inquire_equel(rowcount = "rowcount");
if (rowcount == 0)
return(MR_NO_MATCH);
if (rowcount != 1)
return(MR_NO_QUOTA);
incremental_clear_before();
-## repeat append nfsquota (#users_id = @users_id, filsys_id = values.value,
-## #quota = @quota, phys_id = @pid, modtime = "now",
-## modby = @who, modwith = @entity)
+## repeat append #quota (entity_id = @users_id, filsys_id = values.value,
+## type = "USER",
+## #quota = @quota, phys_id = @pid, modtime = "now",
+## modby = @who, modwith = @entity)
## where values.name = "filsys_id"
if (ingres_errno) return(mr_errcode);
## inquire_equel(rowcount = "rowcount");
if (rowcount != 1)
return(MR_INTERNAL);
aargv[0] = login;
- aargv[1] = login;
- sprintf(buffer, "nq.users_id = %d and nq.filsys_id = values.value and values.name = \"filsys_id\"", users_id);
- incremental_after("nfsquota", buffer, aargv);
+ aargv[1] = "USER";
+ aargv[2] = login;
+ sprintf(buffer, "q.entity_id = %d and q.filsys_id = values.value and q.type = \"USER\" and values.name = \"filsys_id\"", users_id);
+ incremental_after("quota", buffer, aargv);
com_err(whoami, 0, "quota of %d assigned", quota);
if (ingres_errno) return(mr_errcode);
## where tblstats.table = "users"
## repeat replace tblstats (appends = tblstats.appends + 1, modtime = "now")
## where tblstats.table = "list" or tblstats.table = "filesys" or
-## tblstats.table = "nfsquota"
+## tblstats.table = "quota"
if (ingres_errno) return(mr_errcode);
return(MR_SUCCESS);
##}