umka/tools/mksamehash.c

481 lines
30 KiB
C

/*
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 <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#define XFS_NAMES_CNT 1000
#define XFS_NAME_SEGMENT_LEN 12
#define XFS_MAX_COUNTERS 4
char xfs_samehash[XFS_NAMES_CNT][XFS_NAME_SEGMENT_LEN] = {
"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",
};
/*
#define XFS_NAMES_CNT 1000
#define XFS_NAME_SEGMENT_LEN 7
#define XFS_MAX_COUNTERS 4
char xfs_samehash[XFS_NAMES_CNT][XFS_NAME_SEGMENT_LEN] = {
"0000000", "00P0006", "00p0004", "0100008", "080000p", "08P000v", "08p000t",
"090000x", "0A00078", "0H0007p", "0HP007v", "0Hp007t", "0I0007x", "0JP007f",
"0Jp007d", "0K0007h", "0KP007n", "0Kp007l", "0L0007P", "0LP007V", "0Lp007T",
"0M0007X", "0NP007F", "0Np007D", "0O0007H", "0OP007N", "0Op007L", "0P00060",
"0PP0066", "0Pp0064", "0Q00068", "0X0006p", "0XP006v", "0Xp006t", "0Y0006x",
"0ZP006f", "0Zp006d", "0a00058", "0h0005p", "0hP005v", "0hp005t", "0i0005x",
"0jP005f", "0jp005d", "0k0005h", "0kP005n", "0kp005l", "0l0005P", "0lP005V",
"0lp005T", "0m0005X", "0nP005F", "0np005D", "0o0005H", "0oP005N", "0op005L",
"0p00040", "0pP0046", "0pp0044", "0q00048", "0x0004p", "0xP004v", "0xp004t",
"0y0004x", "0zP004f", "0zp004d", "1000080", "10P0086", "10p0084", "1100088",
"180008p", "18P008v", "18p008t", "190008x", "80000p0", "80P00p6", "80p00p4",
"81000p8", "88000pp", "88P00pv", "88p00pt", "89000px", "8A000w8", "8H000wp",
"8HP00wv", "8Hp00wt", "8I000wx", "8JP00wf", "8Jp00wd", "8K000wh", "8KP00wn",
"8Kp00wl", "8L000wP", "8LP00wV", "8Lp00wT", "8M000wX", "8NP00wF", "8Np00wD",
"8O000wH", "8OP00wN", "8Op00wL", "8P000v0", "8PP00v6", "8Pp00v4", "8Q000v8",
"8X000vp", "8XP00vv", "8Xp00vt", "8Y000vx", "8ZP00vf", "8Zp00vd", "8a000u8",
"8h000up", "8hP00uv", "8hp00ut", "8i000ux", "8jP00uf", "8jp00ud", "8k000uh",
"8kP00un", "8kp00ul", "8l000uP", "8lP00uV", "8lp00uT", "8m000uX", "8nP00uF",
"8np00uD", "8o000uH", "8oP00uN", "8op00uL", "8p000t0", "8pP00t6", "8pp00t4",
"8q000t8", "8x000tp", "8xP00tv", "8xp00tt", "8y000tx", "8zP00tf", "8zp00td",
"90000x0", "90P00x6", "90p00x4", "91000x8", "98000xp", "98P00xv", "98p00xt",
"99000xx", "A000780", "A0P0786", "A0p0784", "A100788", "A80078p", "A8P078v",
"A8p078t", "A90078x", "H0007p0", "H0P07p6", "H0p07p4", "H1007p8", "H8007pp",
"H8P07pv", "H8p07pt", "H9007px", "HA007w8", "HH007wp", "HHP07wv", "HHp07wt",
"HI007wx", "HJP07wf", "HJp07wd", "HK007wh", "HKP07wn", "HKp07wl", "HL007wP",
"HLP07wV", "HLp07wT", "HM007wX", "HNP07wF", "HNp07wD", "HO007wH", "HOP07wN",
"HOp07wL", "HP007v0", "HPP07v6", "HPp07v4", "HQ007v8", "HX007vp", "HXP07vv",
"HXp07vt", "HY007vx", "HZP07vf", "HZp07vd", "Ha007u8", "Hh007up", "HhP07uv",
"Hhp07ut", "Hi007ux", "HjP07uf", "Hjp07ud", "Hk007uh", "HkP07un", "Hkp07ul",
"Hl007uP", "HlP07uV", "Hlp07uT", "Hm007uX", "HnP07uF", "Hnp07uD", "Ho007uH",
"HoP07uN", "Hop07uL", "Hp007t0", "HpP07t6", "Hpp07t4", "Hq007t8", "Hx007tp",
"HxP07tv", "Hxp07tt", "Hy007tx", "HzP07tf", "Hzp07td", "I0007x0", "I0P07x6",
"I0p07x4", "I1007x8", "I8007xp", "I8P07xv", "I8p07xt", "I9007xx", "JA007g8",
"JH007gp", "JHP07gv", "JHp07gt", "JI007gx", "JJP07gf", "JJp07gd", "JK007gh",
"JKP07gn", "JKp07gl", "JL007gP", "JLP07gV", "JLp07gT", "JM007gX", "JNP07gF",
"JNp07gD", "JO007gH", "JOP07gN", "JOp07gL", "JP007f0", "JPP07f6", "JPp07f4",
"JQ007f8", "JX007fp", "JXP07fv", "JXp07ft", "JY007fx", "JZP07ff", "JZp07fd",
"Ja007e8", "Jh007ep", "JhP07ev", "Jhp07et", "Ji007ex", "JjP07ef", "Jjp07ed",
"Jk007eh", "JkP07en", "Jkp07el", "Jl007eP", "JlP07eV", "Jlp07eT", "Jm007eX",
"JnP07eF", "Jnp07eD", "Jo007eH", "JoP07eN", "Jop07eL", "Jp007d0", "JpP07d6",
"Jpp07d4", "Jq007d8", "Jx007dp", "JxP07dv", "Jxp07dt", "Jy007dx", "JzP07df",
"Jzp07dd", "K0007h0", "K0P07h6", "K0p07h4", "K1007h8", "K8007hp", "K8P07hv",
"K8p07ht", "K9007hx", "KA007o8", "KH007op", "KHP07ov", "KHp07ot", "KI007ox",
"KJP07of", "KJp07od", "KK007oh", "KKP07on", "KKp07ol", "KL007oP", "KLP07oV",
"KLp07oT", "KM007oX", "KNP07oF", "KNp07oD", "KO007oH", "KOP07oN", "KOp07oL",
"KP007n0", "KPP07n6", "KPp07n4", "KQ007n8", "KX007np", "KXP07nv", "KXp07nt",
"KY007nx", "KZP07nf", "KZp07nd", "Ka007m8", "Kh007mp", "KhP07mv", "Khp07mt",
"Ki007mx", "KjP07mf", "Kjp07md", "Kk007mh", "KkP07mn", "Kkp07ml", "Kl007mP",
"KlP07mV", "Klp07mT", "Km007mX", "KnP07mF", "Knp07mD", "Ko007mH", "KoP07mN",
"Kop07mL", "Kp007l0", "KpP07l6", "Kpp07l4", "Kq007l8", "Kx007lp", "KxP07lv",
"Kxp07lt", "Ky007lx", "KzP07lf", "Kzp07ld", "L0007P0", "L0P07P6", "L0p07P4",
"L1007P8", "L8007Pp", "L8P07Pv", "L8p07Pt", "L9007Px", "LA007W8", "LH007Wp",
"LHP07Wv", "LHp07Wt", "LI007Wx", "LJP07Wf", "LJp07Wd", "LK007Wh", "LKP07Wn",
"LKp07Wl", "LL007WP", "LLP07WV", "LLp07WT", "LM007WX", "LNP07WF", "LNp07WD",
"LO007WH", "LOP07WN", "LOp07WL", "LP007V0", "LPP07V6", "LPp07V4", "LQ007V8",
"LX007Vp", "LXP07Vv", "LXp07Vt", "LY007Vx", "LZP07Vf", "LZp07Vd", "La007U8",
"Lh007Up", "LhP07Uv", "Lhp07Ut", "Li007Ux", "LjP07Uf", "Ljp07Ud", "Lk007Uh",
"LkP07Un", "Lkp07Ul", "Ll007UP", "LlP07UV", "Llp07UT", "Lm007UX", "LnP07UF",
"Lnp07UD", "Lo007UH", "LoP07UN", "Lop07UL", "Lp007T0", "LpP07T6", "Lpp07T4",
"Lq007T8", "Lx007Tp", "LxP07Tv", "Lxp07Tt", "Ly007Tx", "LzP07Tf", "Lzp07Td",
"M0007X0", "M0P07X6", "M0p07X4", "M1007X8", "M8007Xp", "M8P07Xv", "M8p07Xt",
"M9007Xx", "NA007G8", "NH007Gp", "NHP07Gv", "NHp07Gt", "NI007Gx", "NJP07Gf",
"NJp07Gd", "NK007Gh", "NKP07Gn", "NKp07Gl", "NL007GP", "NLP07GV", "NLp07GT",
"NM007GX", "NNP07GF", "NNp07GD", "NO007GH", "NOP07GN", "NOp07GL", "NP007F0",
"NPP07F6", "NPp07F4", "NQ007F8", "NX007Fp", "NXP07Fv", "NXp07Ft", "NY007Fx",
"NZP07Ff", "NZp07Fd", "Na007E8", "Nh007Ep", "NhP07Ev", "Nhp07Et", "Ni007Ex",
"NjP07Ef", "Njp07Ed", "Nk007Eh", "NkP07En", "Nkp07El", "Nl007EP", "NlP07EV",
"Nlp07ET", "Nm007EX", "NnP07EF", "Nnp07ED", "No007EH", "NoP07EN", "Nop07EL",
"Np007D0", "NpP07D6", "Npp07D4", "Nq007D8", "Nx007Dp", "NxP07Dv", "Nxp07Dt",
"Ny007Dx", "NzP07Df", "Nzp07Dd", "O0007H0", "O0P07H6", "O0p07H4", "O1007H8",
"O8007Hp", "O8P07Hv", "O8p07Ht", "O9007Hx", "OA007O8", "OH007Op", "OHP07Ov",
"OHp07Ot", "OI007Ox", "OJP07Of", "OJp07Od", "OK007Oh", "OKP07On", "OKp07Ol",
"OL007OP", "OLP07OV", "OLp07OT", "OM007OX", "ONP07OF", "ONp07OD", "OO007OH",
"OOP07ON", "OOp07OL", "OP007N0", "OPP07N6", "OPp07N4", "OQ007N8", "OX007Np",
"OXP07Nv", "OXp07Nt", "OY007Nx", "OZP07Nf", "OZp07Nd", "Oa007M8", "Oh007Mp",
"OhP07Mv", "Ohp07Mt", "Oi007Mx", "OjP07Mf", "Ojp07Md", "Ok007Mh", "OkP07Mn",
"Okp07Ml", "Ol007MP", "OlP07MV", "Olp07MT", "Om007MX", "OnP07MF", "Onp07MD",
"Oo007MH", "OoP07MN", "Oop07ML", "Op007L0", "OpP07L6", "Opp07L4", "Oq007L8",
"Ox007Lp", "OxP07Lv", "Oxp07Lt", "Oy007Lx", "OzP07Lf", "Ozp07Ld", "P000600",
"P0P0606", "P0p0604", "P100608", "P80060p", "P8P060v", "P8p060t", "P90060x",
"PA00678", "PH0067p", "PHP067v", "PHp067t", "PI0067x", "PJP067f", "PJp067d",
"PK0067h", "PKP067n", "PKp067l", "PL0067P", "PLP067V", "PLp067T", "PM0067X",
"PNP067F", "PNp067D", "PO0067H", "POP067N", "POp067L", "PP00660", "PPP0666",
"PPp0664", "PQ00668", "PX0066p", "PXP066v", "PXp066t", "PY0066x", "PZP066f",
"PZp066d", "Pa00658", "Ph0065p", "PhP065v", "Php065t", "Pi0065x", "PjP065f",
"Pjp065d", "Pk0065h", "PkP065n", "Pkp065l", "Pl0065P", "PlP065V", "Plp065T",
"Pm0065X", "PnP065F", "Pnp065D", "Po0065H", "PoP065N", "Pop065L", "Pp00640",
"PpP0646", "Ppp0644", "Pq00648", "Px0064p", "PxP064v", "Pxp064t", "Py0064x",
"PzP064f", "Pzp064d", "Q000680", "Q0P0686", "Q0p0684", "Q100688", "Q80068p",
"Q8P068v", "Q8p068t", "Q90068x", "X0006p0", "X0P06p6", "X0p06p4", "X1006p8",
"X8006pp", "X8P06pv", "X8p06pt", "X9006px", "XA006w8", "XH006wp", "XHP06wv",
"XHp06wt", "XI006wx", "XJP06wf", "XJp06wd", "XK006wh", "XKP06wn", "XKp06wl",
"XL006wP", "XLP06wV", "XLp06wT", "XM006wX", "XNP06wF", "XNp06wD", "XO006wH",
"XOP06wN", "XOp06wL", "XP006v0", "XPP06v6", "XPp06v4", "XQ006v8", "XX006vp",
"XXP06vv", "XXp06vt", "XY006vx", "XZP06vf", "XZp06vd", "Xa006u8", "Xh006up",
"XhP06uv", "Xhp06ut", "Xi006ux", "XjP06uf", "Xjp06ud", "Xk006uh", "XkP06un",
"Xkp06ul", "Xl006uP", "XlP06uV", "Xlp06uT", "Xm006uX", "XnP06uF", "Xnp06uD",
"Xo006uH", "XoP06uN", "Xop06uL", "Xp006t0", "XpP06t6", "Xpp06t4", "Xq006t8",
"Xx006tp", "XxP06tv", "Xxp06tt", "Xy006tx", "XzP06tf", "Xzp06td", "Y0006x0",
"Y0P06x6", "Y0p06x4", "Y1006x8", "Y8006xp", "Y8P06xv", "Y8p06xt", "Y9006xx",
"ZA006g8", "ZH006gp", "ZHP06gv", "ZHp06gt", "ZI006gx", "ZJP06gf", "ZJp06gd",
"ZK006gh", "ZKP06gn", "ZKp06gl", "ZL006gP", "ZLP06gV", "ZLp06gT", "ZM006gX",
"ZNP06gF", "ZNp06gD", "ZO006gH", "ZOP06gN", "ZOp06gL", "ZP006f0", "ZPP06f6",
"ZPp06f4", "ZQ006f8", "ZX006fp", "ZXP06fv", "ZXp06ft", "ZY006fx", "ZZP06ff",
"ZZp06fd", "Za006e8", "Zh006ep", "ZhP06ev", "Zhp06et", "Zi006ex", "ZjP06ef",
"Zjp06ed", "Zk006eh", "ZkP06en", "Zkp06el", "Zl006eP", "ZlP06eV", "Zlp06eT",
"Zm006eX", "ZnP06eF", "Znp06eD", "Zo006eH", "ZoP06eN", "Zop06eL", "Zp006d0",
"ZpP06d6", "Zpp06d4", "Zq006d8", "Zx006dp", "ZxP06dv", "Zxp06dt", "Zy006dx",
"ZzP06df", "Zzp06dd", "a000580", "a0P0586", "a0p0584", "a100588", "a80058p",
"a8P058v", "a8p058t", "a90058x", "h0005p0", "h0P05p6", "h0p05p4", "h1005p8",
"h8005pp", "h8P05pv", "h8p05pt", "h9005px", "hA005w8", "hH005wp", "hHP05wv",
"hHp05wt", "hI005wx", "hJP05wf", "hJp05wd", "hK005wh", "hKP05wn", "hKp05wl",
"hL005wP", "hLP05wV", "hLp05wT", "hM005wX", "hNP05wF", "hNp05wD", "hO005wH",
"hOP05wN", "hOp05wL", "hP005v0", "hPP05v6", "hPp05v4", "hQ005v8", "hX005vp",
"hXP05vv", "hXp05vt", "hY005vx", "hZP05vf", "hZp05vd", "ha005u8", "hh005up",
"hhP05uv", "hhp05ut", "hi005ux", "hjP05uf", "hjp05ud", "hk005uh", "hkP05un",
"hkp05ul", "hl005uP", "hlP05uV", "hlp05uT", "hm005uX", "hnP05uF", "hnp05uD",
"ho005uH", "hoP05uN", "hop05uL", "hp005t0", "hpP05t6", "hpp05t4", "hq005t8",
"hx005tp", "hxP05tv", "hxp05tt", "hy005tx", "hzP05tf", "hzp05td", "i0005x0",
"i0P05x6", "i0p05x4", "i1005x8", "i8005xp", "i8P05xv", "i8p05xt", "i9005xx",
"jA005g8", "jH005gp", "jHP05gv", "jHp05gt", "jI005gx", "jJP05gf", "jJp05gd",
"jK005gh", "jKP05gn", "jKp05gl", "jL005gP", "jLP05gV", "jLp05gT", "jM005gX",
"jNP05gF", "jNp05gD", "jO005gH", "jOP05gN", "jOp05gL", "jP005f0", "jPP05f6",
"jPp05f4", "jQ005f8", "jX005fp", "jXP05fv", "jXp05ft", "jY005fx", "jZP05ff",
"jZp05fd", "ja005e8", "jh005ep", "jhP05ev", "jhp05et", "ji005ex", "jjP05ef",
"jjp05ed", "jk005eh", "jkP05en", "jkp05el", "jl005eP", "jlP05eV", "jlp05eT",
"jm005eX", "jnP05eF", "jnp05eD", "jo005eH", "joP05eN", "jop05eL", "jp005d0",
"jpP05d6", "jpp05d4", "jq005d8", "jx005dp", "jxP05dv", "jxp05dt", "jy005dx",
"jzP05df", "jzp05dd", "k0005h0", "k0P05h6", "k0p05h4", "k1005h8", "k8005hp",
"k8P05hv", "k8p05ht", "k9005hx", "kA005o8", "kH005op", "kHP05ov", "kHp05ot",
"kI005ox", "kJP05of", "kJp05od", "kK005oh", "kKP05on", "kKp05ol", "kL005oP",
"kLP05oV", "kLp05oT", "kM005oX", "kNP05oF", "kNp05oD", "kO005oH", "kOP05oN",
"kOp05oL", "kP005n0", "kPP05n6", "kPp05n4", "kQ005n8", "kX005np", "kXP05nv",
"kXp05nt", "kY005nx", "kZP05nf", "kZp05nd", "ka005m8", "kh005mp", "khP05mv",
"khp05mt", "ki005mx", "kjP05mf", "kjp05md", "kk005mh", "kkP05mn", "kkp05ml",
"kl005mP", "klP05mV", "klp05mT", "km005mX", "knP05mF", "knp05mD", "ko005mH",
"koP05mN", "kop05mL", "kp005l0", "kpP05l6", "kpp05l4", "kq005l8", "kx005lp",
"kxP05lv", "kxp05lt", "ky005lx", "kzP05lf", "kzp05ld", "l0005P0", "l0P05P6",
"l0p05P4", "l1005P8", "l8005Pp", "l8P05Pv", "l8p05Pt", "l9005Px", "lA005W8",
"lH005Wp", "lHP05Wv", "lHp05Wt", "lI005Wx", "lJP05Wf", "lJp05Wd", "lK005Wh",
"lKP05Wn", "lKp05Wl", "lL005WP", "lLP05WV", "lLp05WT", "lM005WX", "lNP05WF",
"lNp05WD", "lO005WH", "lOP05WN", "lOp05WL", "lP005V0", "lPP05V6", "lPp05V4",
"lQ005V8", "lX005Vp", "lXP05Vv", "lXp05Vt", "lY005Vx", "lZP05Vf",
};
*/
bool quiet = false;
void xfs_iterate_name_segment(int dirfd, char *dirname, size_t cidx,
size_t ccnt, uint64_t *left) {
for (size_t i = 0; i < XFS_NAMES_CNT; i++) {
memcpy(dirname + 2 + (1 + XFS_NAME_SEGMENT_LEN)*cidx, xfs_samehash + i,
XFS_NAME_SEGMENT_LEN);
if (cidx + 1 < ccnt) {
xfs_iterate_name_segment(dirfd, dirname, cidx+1, ccnt, left);
} else {
if (!left[0]) {
return;
}
if(mkdirat(dirfd, dirname, 0755)) {
fprintf(stderr, "Can't mkdir %s: %s\n", dirname, strerror(errno));
exit(1);
}
left[0]--;
}
}
}
int main(int argc, char *argv[])
{
const char *path;
uint64_t left;
if (argc < 3) {
fprintf(stderr, "mkdirrange <directory> <count>\n");
exit(1);
}
path = argv[1];
sscanf(argv[2], "%" SCNu64, &left);
if (argc > 3 && !strcmp(argv[3], "-q")) {
quiet = true;
}
int dirfd = open(path, O_DIRECTORY);
if (dirfd == -1) {
fprintf(stderr, "Can't open %s: %s\n", path, strerror(errno));
exit(1);
}
char dirname[128] = "d_____________________________________________";
size_t ccnt = 1;
for (uint64_t last_name = XFS_NAMES_CNT;
last_name < left;
last_name *= XFS_NAMES_CNT, ccnt++) {}
dirname[1 + (1 + XFS_NAME_SEGMENT_LEN)*ccnt] = '\0';
xfs_iterate_name_segment(dirfd, dirname, 0, ccnt, &left);
return 0;
}