X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/blobdiff_plain/1c934a3193e41bf6663b4f86a8f007996a2d8e43..67805159a972397342c342ee735c8acd640e1399:/dbck/phase2.qc diff --git a/dbck/phase2.qc b/dbck/phase2.qc index 0cf2af75..9a0840d6 100644 --- a/dbck/phase2.qc +++ b/dbck/phase2.qc @@ -7,7 +7,7 @@ #include #include -#include +#include #include "dbck.h" static char phase2_qc_rcsid[] = "$Header$"; @@ -348,35 +348,32 @@ int hint; struct nfsphys *n; struct machine *m; - if (f->type == 'N' || f->type == 'R') { - if (!hash_lookup(machines, f->mach_id)) { - printf("Filesys %s with bad machine %d\n", f->name, f->mach_id); - if (single_fix("Fix", 0)) { -## replace filesys (mach_id = 0) where filesys.filsys_id = id -## inquire_equel(rowcount = "rowcount") - if (rowcount > 0) - printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies"); - else - printf("Not fixed\n"); - modified("filesys"); - f->mach_id = 0; - } + if (!hash_lookup(machines, f->mach_id)) { + printf("Filesys %s with bad machine %d\n", f->name, f->mach_id); + if (single_fix("Fix", 0)) { +## replace filesys (mach_id = 0) where filesys.filsys_id = id +## inquire_equel(rowcount = "rowcount") + if (rowcount > 0) + printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies"); + else + printf("Not fixed\n"); + modified("filesys"); + f->mach_id = 0; } } - if (f->type == 'N' || f->type == 'R' || f->type == 'A') { - if (!hash_lookup(users, f->owner)) { - printf("Filesys %s with bad owning user %d\n", f->name, f->owner); - if (single_fix("Fix", 1)) { - zero_fix("filesys", "owner", "filsys_id", f->filsys_id); - f->owner = 0; - } + + if (!hash_lookup(users, f->owner)) { + printf("Filesys %s with bad owning user %d\n", f->name, f->owner); + if (single_fix("Fix", 1)) { + zero_fix("filesys", "owner", "filsys_id", f->filsys_id); + f->owner = 0; } - if (!hash_lookup(lists, f->owners)) { - printf("Filesys %s with bad owning group %d\n", f->name, f->owners); - if (single_fix("Fix", 1)) { - zero_fix("filesys", "owners", "filsys_id", f->filsys_id); - f->owners = 0; - } + } + if (!hash_lookup(lists, f->owners)) { + printf("Filesys %s with bad owning group %d\n", f->name, f->owners); + if (single_fix("Fix", 1)) { + zero_fix("filesys", "owners", "filsys_id", f->filsys_id); + f->owners = 0; } } @@ -406,7 +403,7 @@ int hint; id2 = f->filsys_id; id3 = f->mach_id; if (set_next_object_id("nfsphys_id", "nfsphys") != - SMS_SUCCESS) { + MR_SUCCESS) { printf("Unable to assign unique ID\n"); return; } @@ -505,6 +502,9 @@ struct filesys *f; case 'F': t = "FSGROUP"; break; + case 'M': + t = "MUL"; + break; default: t = "???"; } @@ -547,50 +547,90 @@ struct filesys *f; ##{ ## int id1, found = 1; -## retrieve (id1 = nfsquota.filsys_id) where nfsquota.users_id = id { +## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and +## quota.type = "USER" { found = 0; - printf("NFSquota on fs %d for non-existant user %d\n", id1, id); + printf("Quota on fs %d for non-existant user %d\n", id1, id); ## } return(found); ##} -fix_quota_nouser(id) -{ - single_delete("nfsquota", "users_id", id); -} +##show_quota_nolist(id) +##int id; +##{ +## int id1, found = 1; + +## retrieve (id1 = quota.filsys_id) where quota.entity_id = id and +## quota.type = "GROUP" { + found = 0; + printf("Quota on fs %d for non-existant list %d\n", id1, id); +## } + return(found); +##} + +##fix_quota_nouser(id) +##int id; +##{ +## int rowcount, id1; + + id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id; +## delete quota where quota.entity_id = id and quota.type = "USER" +## inquire_equel(rowcount = "rowcount") + if (rowcount > 0) + printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies"); + else + printf("Not deleted\n"); + modified("quota"); +##} + +##fix_quota_nolist(id) +##int id; +##{ +## int rowcount, id1; + + id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id; +## delete quota where quota.entity_id = id and quota.type = "GROUP" +## inquire_equel(rowcount = "rowcount") + if (rowcount > 0) + printf("%d entr%s deleted\n",rowcount, rowcount==1?"y":"ies"); + else + printf("Not deleted\n"); + modified("quota"); +##} ##show_quota_nofs(id) ##int id; ##{ ## int id1, found = 1; - struct user *u; +## char type[9]; -## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id { - u = (struct user *)hash_lookup(users, id1); +## retrieve (id1 = quota.entity_id, type = quota.#type) +## where quota.filsys_id = id { found = 0; - printf("NFSquota for user %s on non-existant filesys %d\n", u->login, id); + printf("Quota for %s %d on non-existant filesys %d\n", type, id1, id); ## } return(found); ##} fix_quota_nofs(id) { - single_delete("nfsquota", "filsys_id", id); + single_delete("quota", "filsys_id", id); } ##show_quota_wrongpid(id) ##int id; ##{ ## int id1, found = 1; +## char type[9]; struct user *u; struct filesys *f; f = (struct filesys *)hash_lookup(filesys, id); -## retrieve (id1 = nfsquota.users_id) where nfsquota.filsys_id = id { - u = (struct user *)hash_lookup(users, id1); +## retrieve (id1 = quota.entity_id, type = quota.#type) +## where quota.filsys_id = id { found = 0; - printf("NFSquota for user %s on filesys %s has wrong phys_id %d\n", - u->login, f->name, id); + printf("Quota for %s %d on filesys %s has wrong phys_id %d\n", + type, id1, f->name, id); ## } return(found); ##} @@ -601,14 +641,14 @@ fix_quota_nofs(id) ## int rowcount, id1; id1 = ((struct filesys *)hash_lookup(filesys, id))->phys_id; -## replace nfsquota (phys_id = id1) where nfsquota.filsys_id = id and -## nfsquota.phys_id != id1 +## replace quota (phys_id = id1) where quota.filsys_id = id and +## quota.phys_id != id1 ## inquire_equel(rowcount = "rowcount") if (rowcount > 0) printf("%d entr%s fixed\n",rowcount, rowcount==1?"y":"ies"); else printf("Not fixed\n"); - modified("nfsquota"); + modified("quota"); ##} ##show_srv_user(id) @@ -787,7 +827,7 @@ phase2() else l->members++; ## } - generic_delete(sq1, show_member_list, "members", "list_id", 1); + generic_delete(sq1, show_member_list, "imembers", "list_id", 1); generic_fix(sq2, show_mem_user, "Delete", del_mem_user, 1); generic_fix(sq3, show_mem_list, "Delete", del_mem_list, 1); generic_fix(sq4, show_mem_str, "Delete", del_mem_str, 1); @@ -829,23 +869,23 @@ phase2() ## retrieve (id1 = fsgroup.group_id, id2 = fsgroup.filsys_id) { if (!(f = (struct filesys *) hash_lookup(filesys, id1))) sq_save_data(sq1, id1); - if (f->type != 'F') - sq_save_data(sq2, f); if (!hash_lookup(filesys, id2)) sq_save_data(sq3, id2); ## } generic_delete(sq1, show_fsg_missing, "fsgroup", "group_id", 0); - generic_fix(sq2, show_fsg_type, "Change to \"FSTYPE\"", fix_fsg_type, 0); generic_delete(sq3, show_fsg_nomember, "fsgroup", "filsys_id", 1); - dprintf("Checking nfsquota...\n"); + dprintf("Checking quotas...\n"); sq1 = sq_create(); sq2 = sq_create(); sq3 = sq_create(); -## retrieve (id1 = nfsquota.users_id, id2 = nfsquota.filsys_id, -## id3 = nfsquota.phys_id, id4 = nfsquota.quota) { - if (id1 != 0 && !hash_lookup(users, id1)) + sq4 = sq_create(); +## retrieve (id1 = quota.entity_id, type = quota.#type, id2 = quota.filsys_id, +## id3 = quota.phys_id, id4 = quota.quota) { + if (type[0] == 'U' && id1 != 0 && !hash_lookup(users, id1)) sq_save_data(sq1, id1); + else if (type[0] == 'G' && !hash_lookup(lists, id1)) + sq_save_data(sq4, id1); else if (!(f = (struct filesys *) hash_lookup(filesys, id2))) sq_save_data(sq2, id2); else if (id3 != f->phys_id || @@ -858,6 +898,7 @@ phase2() generic_fix(sq1, show_quota_nouser, "Delete", fix_quota_nouser, 1); generic_fix(sq2, show_quota_nofs, "Delete", fix_quota_nofs, 0); generic_fix(sq3, show_quota_wrongpid, "Fix", fix_quota_physid, 1); + generic_fix(sq4, show_quota_nolist, "Delete", fix_quota_nolist, 1); dprintf("Not checking zephyr.\n");