Add mksamehash utility to make same-hash directories

Yes, first you generate names with gensamehash (very slow) and then
make many directories with mksamehash (relatively fast).
This commit is contained in:
Ivan Baravy 2023-01-07 02:55:43 +00:00
parent eb243bf14f
commit 4a6f3e3039
3 changed files with 314 additions and 2 deletions

1
.gitignore vendored
View File

@ -13,6 +13,7 @@ umka_gen_devices_dat
tools/mkdirrange
tools/mkdoubledirs
tools/gensamehash
tools/mksamehash
tools/mkfilepattern
tools/lfbviewx
tools/randdir

View File

@ -8,7 +8,7 @@ CFLAGS=$(WARNINGS) $(NOWARNINGS) -std=c11 -O2 \
LDFLAGS=-no-pie
all: mkdirrange mkfilepattern lfbviewx randdir covpreproc mkdoubledirs \
gensamehash
gensamehash mksamehash
gensamehash: gensamehash.c
$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
@ -16,6 +16,9 @@ gensamehash: gensamehash.c
mkdoubledirs: mkdoubledirs.c
$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
mksamehash: mksamehash.c
$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
mkdirrange: mkdirrange.c
$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
@ -35,4 +38,4 @@ covpreproc: covpreproc.c
clean:
rm -f *.o mkdirrange mkfilepattern lfbviewx randdir covpreproc \
mkdoubledirs gensamehash
mkdoubledirs gensamehash mksamehash

308
tools/mksamehash.c Normal file
View File

@ -0,0 +1,308 @@
/*
SPDX-License-Identifier: GPL-2.0-or-later
UMKa - User-Mode KolibriOS developer tools
mksamehash - make directories with names of the same hash
Copyright (C) 2023 Ivan Baravy <dunkaist@gmail.com>
*/
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
char xfs_samehash[1000][12] = {
"000000000000", "000000100008", "000001000080", "000001100088",
"000010000800", "000010100808", "000011000880", "000011100888",
"000100008000", "000100108008", "000101008080", "000101108088",
"000110008800", "000110108808", "000111008880", "000111108888",
"001000080000", "001000180008", "001001080080", "001001180088",
"001010080800", "001010180808", "001011080880", "001011180888",
"001100088000", "001100188008", "001101088080", "001101188088",
"001110088800", "001110188808", "001111088880", "001111188888",
"002000000001", "002000100009", "002001000081", "002001100089",
"002010000801", "002010100809", "002011000881", "002011100889",
"002100008001", "002100108009", "002101008081", "002101108089",
"002110008801", "002110108809", "002111008881", "002111108889",
"003000080001", "003000180009", "003001080081", "003001180089",
"003010080801", "003010180809", "003011080881", "003011180889",
"003100088001", "003100188009", "003101088081", "003101188089",
"003110088801", "003110188809", "003111088881", "003111188889",
"004000000002", "004001000082", "004010000802", "004011000882",
"004100008002", "004101008082", "004110008802", "004111008882",
"005000080002", "005001080082", "005010080802", "005011080882",
"005100088002", "005101088082", "005110088802", "005111088882",
"006000000003", "006001000083", "006010000803", "006011000883",
"006100008003", "006101008083", "006110008803", "006111008883",
"007000080003", "007001080083", "007010080803", "007011080883",
"007100088003", "007101088083", "007110088803", "007111088883",
"008000000004", "008001000084", "008010000804", "008011000884",
"008100008004", "008101008084", "008110008804", "008111008884",
"009000080004", "009001080084", "009010080804", "009011080884",
"009100088004", "009101088084", "009110088804", "009111088884",
"010000800000", "010000900008", "010001800080", "010001900088",
"010010800800", "010010900808", "010011800880", "010011900888",
"010100808000", "010100908008", "010101808080", "010101908088",
"010110808800", "010110908808", "010111808880", "010111908888",
"011000880000", "011000980008", "011001880080", "011001980088",
"011010880800", "011010980808", "011011880880", "011011980888",
"011100888000", "011100988008", "011101888080", "011101988088",
"011110888800", "011110988808", "011111888880", "011111988888",
"012000800001", "012000900009", "012001800081", "012001900089",
"012010800801", "012010900809", "012011800881", "012011900889",
"012100808001", "012100908009", "012101808081", "012101908089",
"012110808801", "012110908809", "012111808881", "012111908889",
"013000880001", "013000980009", "013001880081", "013001980089",
"013010880801", "013010980809", "013011880881", "013011980889",
"013100888001", "013100988009", "013101888081", "013101988089",
"013110888801", "013110988809", "013111888881", "013111988889",
"014000800002", "014001800082", "014010800802", "014011800882",
"014100808002", "014101808082", "014110808802", "014111808882",
"015000880002", "015001880082", "015010880802", "015011880882",
"015100888002", "015101888082", "015110888802", "015111888882",
"016000800003", "016001800083", "016010800803", "016011800883",
"016100808003", "016101808083", "016110808803", "016111808883",
"017000880003", "017001880083", "017010880803", "017011880883",
"017100888003", "017101888083", "017110888803", "017111888883",
"018000800004", "018001800084", "018010800804", "018011800884",
"018100808004", "018101808084", "018110808804", "018111808884",
"019000880004", "019001880084", "019010880804", "019011880884",
"019100888004", "019101888084", "019110888804", "019111888884",
"020000000010", "020000100018", "020001000090", "020001100098",
"020010000810", "020010100818", "020011000890", "020011100898",
"020100008010", "020100108018", "020101008090", "020101108098",
"020110008810", "020110108818", "020111008890", "020111108898",
"021000080010", "021000180018", "021001080090", "021001180098",
"021010080810", "021010180818", "021011080890", "021011180898",
"021100088010", "021100188018", "021101088090", "021101188098",
"021110088810", "021110188818", "021111088890", "021111188898",
"022000000011", "022000100019", "022001000091", "022001100099",
"022010000811", "022010100819", "022011000891", "022011100899",
"022100008011", "022100108019", "022101008091", "022101108099",
"022110008811", "022110108819", "022111008891", "022111108899",
"023000080011", "023000180019", "023001080091", "023001180099",
"023010080811", "023010180819", "023011080891", "023011180899",
"023100088011", "023100188019", "023101088091", "023101188099",
"023110088811", "023110188819", "023111088891", "023111188899",
"024000000012", "024001000092", "024010000812", "024011000892",
"024100008012", "024101008092", "024110008812", "024111008892",
"025000080012", "025001080092", "025010080812", "025011080892",
"025100088012", "025101088092", "025110088812", "025111088892",
"026000000013", "026001000093", "026010000813", "026011000893",
"026100008013", "026101008093", "026110008813", "026111008893",
"027000080013", "027001080093", "027010080813", "027011080893",
"027100088013", "027101088093", "027110088813", "027111088893",
"028000000014", "028001000094", "028010000814", "028011000894",
"028100008014", "028101008094", "028110008814", "028111008894",
"029000080014", "029001080094", "029010080814", "029011080894",
"029100088014", "029101088094", "029110088814", "029111088894",
"030000800010", "030000900018", "030001800090", "030001900098",
"030010800810", "030010900818", "030011800890", "030011900898",
"030100808010", "030100908018", "030101808090", "030101908098",
"030110808810", "030110908818", "030111808890", "030111908898",
"031000880010", "031000980018", "031001880090", "031001980098",
"031010880810", "031010980818", "031011880890", "031011980898",
"031100888010", "031100988018", "031101888090", "031101988098",
"031110888810", "031110988818", "031111888890", "031111988898",
"032000800011", "032000900019", "032001800091", "032001900099",
"032010800811", "032010900819", "032011800891", "032011900899",
"032100808011", "032100908019", "032101808091", "032101908099",
"032110808811", "032110908819", "032111808891", "032111908899",
"033000880011", "033000980019", "033001880091", "033001980099",
"033010880811", "033010980819", "033011880891", "033011980899",
"033100888011", "033100988019", "033101888091", "033101988099",
"033110888811", "033110988819", "033111888891", "033111988899",
"034000800012", "034001800092", "034010800812", "034011800892",
"034100808012", "034101808092", "034110808812", "034111808892",
"035000880012", "035001880092", "035010880812", "035011880892",
"035100888012", "035101888092", "035110888812", "035111888892",
"036000800013", "036001800093", "036010800813", "036011800893",
"036100808013", "036101808093", "036110808813", "036111808893",
"037000880013", "037001880093", "037010880813", "037011880893",
"037100888013", "037101888093", "037110888813", "037111888893",
"038000800014", "038001800094", "038010800814", "038011800894",
"038100808014", "038101808094", "038110808814", "038111808894",
"039000880014", "039001880094", "039010880814", "039011880894",
"039100888014", "039101888094", "039110888814", "039111888894",
"040000000020", "040000100028", "040010000820", "040010100828",
"040100008020", "040100108028", "040110008820", "040110108828",
"041000080020", "041000180028", "041010080820", "041010180828",
"041100088020", "041100188028", "041110088820", "041110188828",
"042000000021", "042000100029", "042010000821", "042010100829",
"042100008021", "042100108029", "042110008821", "042110108829",
"043000080021", "043000180029", "043010080821", "043010180829",
"043100088021", "043100188029", "043110088821", "043110188829",
"044000000022", "044010000822", "044100008022", "044110008822",
"045000080022", "045010080822", "045100088022", "045110088822",
"046000000023", "046010000823", "046100008023", "046110008823",
"047000080023", "047010080823", "047100088023", "047110088823",
"048000000024", "048010000824", "048100008024", "048110008824",
"049000080024", "049010080824", "049100088024", "049110088824",
"050000800020", "050000900028", "050010800820", "050010900828",
"050100808020", "050100908028", "050110808820", "050110908828",
"051000880020", "051000980028", "051010880820", "051010980828",
"051100888020", "051100988028", "051110888820", "051110988828",
"052000800021", "052000900029", "052010800821", "052010900829",
"052100808021", "052100908029", "052110808821", "052110908829",
"053000880021", "053000980029", "053010880821", "053010980829",
"053100888021", "053100988029", "053110888821", "053110988829",
"054000800022", "054010800822", "054100808022", "054110808822",
"055000880022", "055010880822", "055100888022", "055110888822",
"056000800023", "056010800823", "056100808023", "056110808823",
"057000880023", "057010880823", "057100888023", "057110888823",
"058000800024", "058010800824", "058100808024", "058110808824",
"059000880024", "059010880824", "059100888024", "059110888824",
"060000000030", "060000100038", "060010000830", "060010100838",
"060100008030", "060100108038", "060110008830", "060110108838",
"061000080030", "061000180038", "061010080830", "061010180838",
"061100088030", "061100188038", "061110088830", "061110188838",
"062000000031", "062000100039", "062010000831", "062010100839",
"062100008031", "062100108039", "062110008831", "062110108839",
"063000080031", "063000180039", "063010080831", "063010180839",
"063100088031", "063100188039", "063110088831", "063110188839",
"064000000032", "064010000832", "064100008032", "064110008832",
"065000080032", "065010080832", "065100088032", "065110088832",
"066000000033", "066010000833", "066100008033", "066110008833",
"067000080033", "067010080833", "067100088033", "067110088833",
"068000000034", "068010000834", "068100008034", "068110008834",
"069000080034", "069010080834", "069100088034", "069110088834",
"070000800030", "070000900038", "070010800830", "070010900838",
"070100808030", "070100908038", "070110808830", "070110908838",
"071000880030", "071000980038", "071010880830", "071010980838",
"071100888030", "071100988038", "071110888830", "071110988838",
"072000800031", "072000900039", "072010800831", "072010900839",
"072100808031", "072100908039", "072110808831", "072110908839",
"073000880031", "073000980039", "073010880831", "073010980839",
"073100888031", "073100988039", "073110888831", "073110988839",
"074000800032", "074010800832", "074100808032", "074110808832",
"075000880032", "075010880832", "075100888032", "075110888832",
"076000800033", "076010800833", "076100808033", "076110808833",
"077000880033", "077010880833", "077100888033", "077110888833",
"078000800034", "078010800834", "078100808034", "078110808834",
"079000880034", "079010880834", "079100888034", "079110888834",
"080000000040", "080000100048", "080010000840", "080010100848",
"080100008040", "080100108048", "080110008840", "080110108848",
"081000080040", "081000180048", "081010080840", "081010180848",
"081100088040", "081100188048", "081110088840", "081110188848",
"082000000041", "082000100049", "082010000841", "082010100849",
"082100008041", "082100108049", "082110008841", "082110108849",
"083000080041", "083000180049", "083010080841", "083010180849",
"083100088041", "083100188049", "083110088841", "083110188849",
"084000000042", "084010000842", "084100008042", "084110008842",
"085000080042", "085010080842", "085100088042", "085110088842",
"086000000043", "086010000843", "086100008043", "086110008843",
"087000080043", "087010080843", "087100088043", "087110088843",
"088000000044", "088010000844", "088100008044", "088110008844",
"089000080044", "089010080844", "089100088044", "089110088844",
"090000800040", "090000900048", "090010800840", "090010900848",
"090100808040", "090100908048", "090110808840", "090110908848",
"091000880040", "091000980048", "091010880840", "091010980848",
"091100888040", "091100988048", "091110888840", "091110988848",
"092000800041", "092000900049", "092010800841", "092010900849",
"092100808041", "092100908049", "092110808841", "092110908849",
"093000880041", "093000980049", "093010880841", "093010980849",
"093100888041", "093100988049", "093110888841", "093110988849",
"094000800042", "094010800842", "094100808042", "094110808842",
"095000880042", "095010880842", "095100888042", "095110888842",
"096000800043", "096010800843", "096100808043", "096110808843",
"097000880043", "097010880843", "097100888043", "097110888843",
"098000800044", "098010800844", "098100808044", "098110808844",
"099000880044", "099010880844", "099100888044", "099110888844",
"100008000000", "100008100008", "100009000080", "100009100088",
"100018000800", "100018100808", "100019000880", "100019100888",
"100108008000", "100108108008", "100109008080", "100109108088",
"100118008800", "100118108808", "100119008880", "100119108888",
"101008080000", "101008180008", "101009080080", "101009180088",
"101018080800", "101018180808", "101019080880", "101019180888",
"101108088000", "101108188008", "101109088080", "101109188088",
"101118088800", "101118188808", "101119088880", "101119188888",
"102008000001", "102008100009", "102009000081", "102009100089",
"102018000801", "102018100809", "102019000881", "102019100889",
"102108008001", "102108108009", "102109008081", "102109108089",
"102118008801", "102118108809", "102119008881", "102119108889",
"103008080001", "103008180009", "103009080081", "103009180089",
"103018080801", "103018180809", "103019080881", "103019180889",
"103108088001", "103108188009", "103109088081", "103109188089",
"103118088801", "103118188809", "103119088881", "103119188889",
"104008000002", "104009000082", "104018000802", "104019000882",
"104108008002", "104109008082", "104118008802", "104119008882",
"105008080002", "105009080082", "105018080802", "105019080882",
"105108088002", "105109088082", "105118088802", "105119088882",
"106008000003", "106009000083", "106018000803", "106019000883",
"106108008003", "106109008083", "106118008803", "106119008883",
"107008080003", "107009080083", "107018080803", "107019080883",
"107108088003", "107109088083", "107118088803", "107119088883",
"108008000004", "108009000084", "108018000804", "108019000884",
"108108008004", "108109008084", "108118008804", "108119008884",
"109008080004", "109009080084", "109018080804", "109019080884",
"109108088004", "109109088084", "109118088804", "109119088884",
"110008800000", "110008900008", "110009800080", "110009900088",
"110018800800", "110018900808", "110019800880", "110019900888",
"110108808000", "110108908008", "110109808080", "110109908088",
"110118808800", "110118908808", "110119808880", "110119908888",
"111008880000", "111008980008", "111009880080", "111009980088",
"111018880800", "111018980808", "111019880880", "111019980888",
"111108888000", "111108988008", "111109888080", "111109988088",
"111118888800", "111118988808", "111119888880", "111119988888",
"112008800001", "112008900009", "112009800081", "112009900089",
"112018800801", "112018900809", "112019800881", "112019900889",
"112108808001", "112108908009", "112109808081", "112109908089",
"112118808801", "112118908809", "112119808881", "112119908889",
"113008880001", "113008980009", "113009880081", "113009980089",
"113018880801", "113018980809", "113019880881", "113019980889",
"113108888001", "113108988009", "113109888081", "113109988089",
"113118888801", "113118988809", "113119888881", "113119988889",
"114008800002", "114009800082", "114018800802", "114019800882",
"114108808002", "114109808082", "114118808802", "114119808882",
"115008880002", "115009880082", "115018880802", "115019880882",
"115108888002", "115109888082", "115118888802", "115119888882",
"116008800003", "116009800083", "116018800803", "116019800883",
"116108808003", "116109808083", "116118808803", "116119808883",
"117008880003", "117009880083", "117018880803", "117019880883",
"117108888003", "117109888083", "117118888803", "117119888883",
"118008800004", "118009800084", "118018800804", "118019800884",
"118108808004", "118109808084", "118118808804", "118119808884",
};
int main(int argc, char *argv[])
{
const char *path;
uint64_t count, total;
if (argc != 3) {
fprintf(stderr, "mkdirrange <directory> <count>\n");
exit(1);
}
path = argv[1];
sscanf(argv[2], "%" SCNu64, &total);
int dirfd = open(path, O_DIRECTORY);
if (dirfd == -1) {
fprintf(stderr, "Can't open %s: %s\n", path, strerror(errno));
exit(1);
}
char dirname[256];
strcpy(dirname, "d_xxxxxxxxxxxx_xxxxxxxxxxxx_xxxxxxxxxxxx");
count = 0;
for(unsigned i = 0; i < 1000 && count < total; i++) {
memcpy(dirname + 2, xfs_samehash + i, 12);
for(unsigned j = 0; j < 1000 && count < total; j++) {
memcpy(dirname + 15, xfs_samehash + j, 12);
// printf("count: %" PRIu64 "\n", count);
for(unsigned k = 0; k < 1000 && count < total; k++, count++) {
memcpy(dirname + 28, xfs_samehash + k, 12);
if(mkdirat(dirfd, dirname, 0755)) {
fprintf(stderr, "Can't mkdir %s: %s\n", dirname, strerror(errno));
exit(1);
}
}
}
}
return 0;
}