## barg10 = fs.lockertype)
## where qual
beforec = 11;
- } else if (!strcmp(table, "nfsquota")) {
+ } else if (!strcmp(table, "quota")) {
strcpy(barg0, argv[0]);
- strcpy(barg1, argv[1]);
- sprintf(buffer, "%s and filesys.filsys_id = nq.filsys_id", qual);
+ if (!strcmp(argv[1], "USER") || !strcmp(argv[1], "GROUP") ||
+ !strcmp(argv[1], "LIST") || !strcmp(argv[1], "ANY")) {
+ strcpy(barg1, argv[1]);
+ strcpy(barg2, argv[2]);
+ } else {
+ strcpy(barg1, "USER");
+ strcpy(barg2, argv[1]);
+ }
+ sprintf(buffer, "%s and filesys.filsys_id = q.filsys_id", qual);
qual = buffer;
-## range of nq is nfsquota
-## retrieve (barg2 = text(nq.quota), barg3 = filesys.name) where qual
- beforec = 4;
+## range of q is quota
+## retrieve (barg3 = text(q.quota), barg4 = filesys.name) where qual
+ beforec = 5;
} else if (!strcmp(table, "list")) {
## retrieve (barg0 = l.name, barg1 = text(l.active),
## barg2 = text(l.public), barg3 = text(l.hidden),
## aarg10 = fs.lockertype)
## where qual
afterc = 11;
- } else if (!strcmp(table, "nfsquota")) {
+ } else if (!strcmp(table, "quota")) {
strcpy(aarg0, argv[0]);
strcpy(aarg1, argv[1]);
- sprintf(buffer, "%s and filesys.filsys_id = nq.filsys_id", qual);
+ strcpy(aarg2, argv[2]);
+ sprintf(buffer, "%s and filesys.filsys_id = q.filsys_id", qual);
qual = buffer;
-## range of nq is nfsquota
-## retrieve (aarg2 = text(nq.quota), aarg3 = filesys.name) where qual
- afterc = 4;
+## range of q is quota
+## retrieve (aarg3 = text(q.quota), aarg4 = filesys.name) where qual
+ afterc = 5;
} else if (!strcmp(table, "list")) {
## retrieve (aarg0 = l.name, aarg1 = text(l.active),
## aarg2 = text(l.public), aarg3 = text(l.hidden),
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"))
* 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;
+## int fid, total, who;
+## char *entity;
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;
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))
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);
## 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);
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");
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);
+ 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);
##}
int setup_ufil();
int setup_dfil();
int setup_dnfp();
-int setup_dnfq();
+int setup_dqot();
int setup_sshi();
int setup_akum();
int followup_ausr();
int followup_gpob();
int followup_glin();
-int followup_anfq();
+int followup_aqot();
int followup_gzcl();
int followup_gsha();
-int followup_gnfq();
+int followup_gqot();
int set_modtime();
int set_modtime_by_id();
static char MOD2[] = "modby";
static char MOD3[] = "modwith";
static char NAME[] = "name";
+static char QUOTA[] = "quota";
+static char QUOTA_TYPE[] = "quota_type";
static char SERVICE[] = "service";
static char SHELL[] = "shell";
static char STATUS[] = "status";
set_nfsphys_modtime,
};
+static char *gqot_fields[] = {
+ FILESYS, TYPE, NAME,
+ FILESYS, TYPE, NAME, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
+};
+
+static struct valobj gqot_valobj[] = {
+ {V_TYPE, 1, QUOTA_TYPE, 0, 0, MR_TYPE},
+ {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
+ {V_SORT, 0, 0, 0, 0, 0},
+};
+
+static struct validate gqot_validate = {
+ gqot_valobj,
+ 3,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ followup_gqot,
+};
+
+static char *gqbf_fields[] = {
+ FILESYS,
+ FILESYS, TYPE, NAME, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
+};
+
+static struct validate gqbf_validate = {
+ VOsort0,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ access_filesys,
+ 0,
+ followup_gqot,
+};
+
+static char *aqot_fields[] = {
+ FILESYS, TYPE, NAME, QUOTA,
+};
+
+static struct valobj aqot_valobj[] = {
+ {V_LOCK, 0, FILESYS, 0, FILSYS_ID, MR_DEADLOCK},
+ {V_ID, 0, FILESYS, LABEL, FILSYS_ID, MR_FILESYS},
+ {V_TYPE, 1, QUOTA_TYPE, 0, 0, MR_TYPE},
+ {V_TYPEDATA, 2, 0, 0, 0, MR_ACE},
+};
+
+static struct validate aqot_validate = {
+ aqot_valobj,
+ 4,
+ FILSYS_ID,
+ "q.filsys_id = %d and q.type = \"%s\" and q.entity_id = %d",
+ 3,
+ 0,
+ 0,
+ 0,
+ followup_aqot,
+};
+
+static struct validate uqot_validate = {
+ aqot_valobj,
+ 4,
+ FILSYS_ID,
+ "q.filsys_id = %d and q.type = \"%s\" and q.entity_id = %d",
+ 3,
+ 0,
+ 0,
+ setup_dqot,
+ followup_aqot,
+};
+
+static struct validate dqot_validate = {
+ aqot_valobj,
+ 4,
+ FILSYS_ID,
+ "q.filsys_id = %d and q.type = \"%s\" and q.entity_id = %d",
+ 3,
+ 0,
+ 0,
+ setup_dqot,
+ 0,
+};
+
static char *gnfq_fields[] = {
FILESYS, LOGIN,
- FILESYS, LOGIN, "quota", DIR, MACHINE, MOD1, MOD2, MOD3,
+ FILESYS, LOGIN, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
};
static struct validate gnfq_validate = {
0,
access_filesys,
0,
- followup_gnfq,
+ followup_gqot,
};
static char *gnqp_fields[] = {
MACHINE, DIR,
- FILESYS, LOGIN, "quota", DIR, MACHINE, MOD1, MOD2, MOD3,
+ FILESYS, LOGIN, QUOTA, DIR, MACHINE, MOD1, MOD2, MOD3,
};
static char *anfq_fields[] = {
- FILESYS, LOGIN, "quota",
+ FILESYS, LOGIN, QUOTA,
};
static struct validate anfq_validate = {
VOfilsys0user1,
3,
- USERS_ID,
- "nq.filsys_id = %d and nq.users_id = %d",
+ FILSYS_ID,
+ "q.filsys_id = %d and q.type = \"USER\" and q.entity_id = %d",
2,
0,
0,
0,
- followup_anfq,
+ followup_aqot,
};
static struct validate unfq_validate = {
VOfilsys0user1,
3,
- USERS_ID,
- "nq.filsys_id = %d and nq.users_id = %d",
+ FILSYS_ID,
+ "q.filsys_id = %d and q.type = \"USER\" and q.entity_id = %d",
2,
0,
0,
- setup_dnfq,
- followup_anfq,
+ setup_dqot,
+ followup_aqot,
};
static struct validate dnfq_validate = {
VOfilsys0user1,
3,
- USERS_ID,
- "nq.filsys_id = %d and nq.users_id = %d",
+ FILSYS_ID,
+ "q.filsys_id = %d and q.entity_id = %d",
2,
0,
0,
- setup_dnfq,
+ setup_dqot,
0,
};
&dnfp_validate,
},
+ {
+ /* Q_GQOT - GET_QUOTA */
+ "get_quota",
+ "gqot",
+ RETRIEVE,
+ "q",
+ QUOTA,
+ "%c = filesys.label, %c = q.type, %c = text(q.entity_id), %c = text(q.quota), %c = text(q.phys_id), %c = machine.name, %c = q.modtime, %c = text(q.modby), %c = q.modwith",
+ gqot_fields,
+ 9,
+ "filesys.label = \"%s\" and q.type = \"%s\" and q.entity_id = %d and filesys.filsys_id = q.filsys_id and machine.mach_id = filesys.mach_id",
+ 3,
+ &gqot_validate,
+ },
+
+ {
+ /* Q_GQBF - GET_QUOTA_BY_FILESYS */
+ "get_quota_by_filesys",
+ "gqbf",
+ RETRIEVE,
+ "q",
+ QUOTA,
+ "%c = filesys.label, %c = q.type, %c = text(q.entity_id), %c = text(q.quota), %c = text(q.phys_id), %c = machine.name, %c = q.modtime, %c = text(q.modby), %c = q.modwith",
+ gqbf_fields,
+ 9,
+ "filesys.label = \"%s\" and filesys.filsys_id = q.filsys_id and machine.mach_id = filesys.mach_id",
+ 1,
+ &gqbf_validate,
+ },
+
+ {
+ /* Q_AQOT - ADD_QUOTA */
+ "add_quota",
+ "aqot",
+ APPEND,
+ "q",
+ QUOTA,
+ "filsys_id = filesys.filsys_id, type = %c, entity_id = %i4, quota = int4(%c), phys_id = filesys.phys_id",
+ aqot_fields,
+ 3,
+ "filesys.filsys_id = %d",
+ 1,
+ &aqot_validate,
+ },
+
+ {
+ /* Q_UQOT - UPDATE_QUOTA */
+ "update_quota",
+ "uqot",
+ UPDATE,
+ "q",
+ QUOTA,
+ "quota = int4(%c)",
+ aqot_fields,
+ 1,
+ "q.filsys_id = %d and q.type = \"%s\" and q.entity_id = %d",
+ 3,
+ &uqot_validate,
+ },
+
+ {
+ /* Q_DQOT - DELETE_QUOTA */
+ "delete_quota",
+ "dqot",
+ DELETE,
+ "q",
+ QUOTA,
+ (char *)0,
+ aqot_fields,
+ 0,
+ "q.filsys_id = %d and q.type = \"%s\" and q.entity_id = %d",
+ 3,
+ &dqot_validate,
+ },
+
{
/* Q_GNFQ - GET_NFS_QUOTAS */
"get_nfs_quota",
"gnfq",
RETRIEVE,
- "nq",
- "nfsquota",
- "%c = filesys.label, %c = users.login, %c = text(nq.quota), %c = text(nq.phys_id), %c = machine.name, %c = nq.modtime, %c = text(nq.modby), %c = nq.modwith",
+ "q",
+ QUOTA,
+ "%c = filesys.label, %c = users.login, %c = text(q.quota), %c = text(q.phys_id), %c = machine.name, %c = q.modtime, %c = text(q.modby), %c = q.modwith",
gnfq_fields,
8,
- "filesys.label = \"%s\" and nq.users_id = users.users_id and filesys.filsys_id = nq.filsys_id and machine.mach_id = filesys.mach_id and users.login = \"%s\"",
+ "filesys.label = \"%s\" and q.type = \"USER\" and q.entity_id = users.users_id and filesys.filsys_id = q.filsys_id and machine.mach_id = filesys.mach_id and users.login = \"%s\"",
2,
&gnfq_validate,
},
"get_nfs_quotas_by_partition",
"gnqp",
RETRIEVE,
- "nq",
- "nfsquota",
- "%c = filesys.label, %c = users.login, %c = text(nq.quota), %c = nfsphys.dir, %c = machine.name",
+ "q",
+ QUOTA,
+ "%c = filesys.label, %c = users.login, %c = text(q.quota), %c = nfsphys.dir, %c = machine.name",
gnqp_fields,
5,
- "nfsphys.mach_id = %d and nfsphys.dir = \"%s\" and nq.phys_id = nfsphys.nfsphys_id and filesys.filsys_id = nq.filsys_id and users.users_id = nq.users_id and machine.mach_id = nfsphys.mach_id",
+ "nfsphys.mach_id = %d and nfsphys.dir = \"%s\" and q.phys_id = nfsphys.nfsphys_id and filesys.filsys_id = q.filsys_id and q.type = \"USER\" and users.users_id = q.entity_id and machine.mach_id = nfsphys.mach_id",
2,
&VDmach,
},
"add_nfs_quota",
"anfq",
APPEND,
- "nq",
- "nfsquota",
- "filsys_id = filesys.filsys_id, users_id = %i4, quota = int4(%c), phys_id = filesys.phys_id",
+ "q",
+ QUOTA,
+ "filsys_id = filesys.filsys_id, type = \"USER\", entity_id = %i4, quota = int4(%c), phys_id = filesys.phys_id",
anfq_fields,
2,
"filesys.filsys_id = %d",
"update_nfs_quota",
"unfq",
UPDATE,
- "nq",
- "nfsquota",
+ "q",
+ QUOTA,
"quota = int4(%c)",
anfq_fields,
1,
- "nq.filsys_id = %d and nq.users_id = %d",
+ "q.filsys_id = %d and q.type = \"USER\" and q.entity_id = %d",
2,
&unfq_validate,
},
"delete_nfs_quota",
"dnfq",
DELETE,
- "nq",
- "nfsquota",
+ "q",
+ QUOTA,
(char *)0,
anfq_fields,
0,
- "nq.filsys_id = %d and nq.users_id = %d",
+ "q.filsys_id = %d and q.type = \"USER\" and q.entity_id = %d",
2,
&dnfq_validate,
},