| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056 |
- /* This FileX test concentrates on the basic directory create/delete operations. */
- #ifndef FX_STANDALONE_ENABLE
- #include "tx_api.h"
- #endif
- #include "fx_api.h"
- #include "fx_directory.h"
- #include "fx_ram_driver_test.h"
- #include "fx_fault_tolerant.h"
- #include "fx_utility.h"
- #include <stdio.h>
- #define DEMO_STACK_SIZE 4096
- #define CACHE_SIZE 16*128
- #ifdef FX_ENABLE_FAULT_TOLERANT
- #define FAULT_TOLERANT_SIZE FX_FAULT_TOLERANT_MINIMAL_BUFFER_SIZE
- #else
- #define FAULT_TOLERANT_SIZE 0
- #endif
- #define DIR_PATH "MYDIR\\"
- #define DIR_PATH_SIZE (sizeof(DIR_PATH) - 1)
- /* Define the ThreadX and FileX object control blocks... */
- #ifndef FX_STANDALONE_ENABLE
- static TX_THREAD ftest_0;
- #endif
- static FX_MEDIA ram_disk;
- static CHAR name[FX_MAX_LONG_NAME_LEN+50];
- static CHAR volume_name[FX_MAX_LONG_NAME_LEN+1];
- static FX_FILE file_1;
- static FX_FILE file_2;
- static FX_FILE file_3;
- static FX_FILE file_4;
- static FX_FILE file_5;
- static FX_FILE file_6;
- static FX_FILE file_7;
- static FX_FILE file_8;
- static FX_FILE file_9;
- static FX_FILE file_10;
- static FX_FILE file_11;
- static FX_FILE file_12;
- static FX_FILE file_13;
- static FX_FILE file_14;
- static FX_FILE file_15;
- static FX_FILE file_16;
- static FX_FILE file_17;
- static FX_FILE file_18;
- static FX_FILE file_19;
- static FX_FILE file_20;
- static FX_FILE file_21;
- static FX_FILE file_22;
- static FX_FILE file_23;
- static FX_FILE file_24;
- static FX_FILE file_25;
- static FX_FILE file_26;
- static FX_FILE file_27;
- static FX_FILE file_28;
- static FX_FILE file_29;
- static FX_FILE file_30;
- static FX_FILE file_31;
- static FX_FILE file_32;
- static FX_FILE file_33;
- static FX_FILE file_34;
- static FX_FILE file_35;
- static FX_FILE file_36;
- static FX_FILE file_37;
- static FX_FILE file_38;
- static FX_FILE file_39;
- static FX_FILE file_40;
- static FX_FILE file_41;
- static FX_FILE file_42;
- static FX_FILE file_43;
- static FX_FILE file_44;
- static UCHAR buffer[128];
- static UCHAR my_unicode_name[] =
- {0xFF,0xC1, 0xFF,0x00, 0xFF,0x00, 0xFF,0x02,
- 0xFF,0xD6, 0xFF,0xC7, 0xFF,0x00, 0xFF,0xC7,
- 0xFF,0xB9, 0xFF,0x00, 0xFF,0xC7, 0xFF,0xB2,
- 0xFF,0xD6, 0xFF,0xC7, 0xFF,0x00, 0x00,0x00};
- static UCHAR my_unicode_name1[] =
- {0x00,0xFF, 0x00,0xFF, 0x00,0xFF, 0x00,0xFF,
- 0x00,0xFF, 0x00,0xFF, 0x00,0xFF, 0x00,0xFF,
- 0x00,0xFF, 0x00,0xFF, 0x00,0xFF, 0x00,0xFF,
- 0x00,0xFF, 0x00,0xFF, 0x00,0xFF, 0x00,0x00};
- /* Define the counters used in the test application... */
- #ifndef FX_STANDALONE_ENABLE
- static UCHAR *ram_disk_memory;
- static UCHAR *cache_buffer;
- static UCHAR *fault_tolerant_buffer;
- #else
- static UCHAR cache_buffer[CACHE_SIZE];
- static UCHAR fault_tolerant_buffer[FAULT_TOLERANT_SIZE];
- #endif
- extern ULONG _fx_ram_driver_copy_default_format;
- /* Define thread prototypes. */
- void filex_directory_create_delete_application_define(void *first_unused_memory);
- static void ftest_0_entry(ULONG thread_input);
- VOID _fx_ram_driver(FX_MEDIA *media_ptr);
- void test_control_return(UINT status);
- /* Define what the initial system looks like. */
- #ifdef CTEST
- void test_application_define(void *first_unused_memory)
- #else
- void filex_directory_create_delete_application_define(void *first_unused_memory)
- #endif
- {
- #ifndef FX_STANDALONE_ENABLE
- UCHAR *pointer;
-
- /* Setup the working pointer. */
- pointer = (UCHAR *) first_unused_memory;
- /* Create the main thread. */
- tx_thread_create(&ftest_0, "thread 0", ftest_0_entry, 0,
- pointer, DEMO_STACK_SIZE,
- 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
- pointer = pointer + DEMO_STACK_SIZE;
- /* Setup memory for the RAM disk and the sector cache. */
- cache_buffer = pointer;
- pointer = pointer + CACHE_SIZE;
- fault_tolerant_buffer = pointer;
- pointer += FAULT_TOLERANT_SIZE;
- ram_disk_memory = pointer;
- #endif
- /* Initialize the FileX system. */
- fx_system_initialize();
- #ifdef FX_STANDALONE_ENABLE
- ftest_0_entry(0);
- #endif
- }
- /* Define the test threads. */
- static void ftest_0_entry(ULONG thread_input)
- {
- UINT status;
- ULONG temp;
- UINT attributes;
- UINT i;
- #ifdef EXTENDED_NAME_MANGLE_TEST
- UINT j, k, l;
- #endif
- CHAR *name_ptr;
- FX_DIR_ENTRY dir_entry;
- FX_DIR_ENTRY search_directory;
- FX_PARAMETER_NOT_USED(thread_input);
- /* Print out some test information banners. */
- printf("FileX Test: Directory create/delete test...........................");
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- /* We need a larger disk to test the feature of fault tolerant. */
- #ifdef FX_ENABLE_FAULT_TOLERANT
- 512 * 8, // Total sectors
- 256, // Sector size
- 8, // Sectors per cluster
- #else
- 512, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- #endif
- 1, // Heads
- 1); // Sectors per track
- return_if_fail( status == FX_SUCCESS);
-
- /* Attempt to create a directory before the media is opened to generate an error */
- status = fx_directory_create(&ram_disk, "/A0");
- return_if_fail( status == FX_MEDIA_NOT_OPEN);
-
- /* Attempt to delete a directory before the media is opened to generate an error */
- status = fx_directory_delete(&ram_disk, "/A0");
- return_if_fail( status == FX_MEDIA_NOT_OPEN);
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, CACHE_SIZE);
- return_if_fail( status == FX_SUCCESS);
-
- /* We need a larger disk to test the feature of fault tolerant. */
- #ifdef FX_ENABLE_FAULT_TOLERANT
- /* Enable fault tolerant if FX_ENABLE_FAULT_TOLERANT is defined. */
- status = fx_fault_tolerant_enable(&ram_disk, fault_tolerant_buffer, FAULT_TOLERANT_SIZE);
- return_if_fail( status == FX_SUCCESS);
- #endif
- /* Only run this if error checking is enabled */
- #ifndef FX_DISABLE_ERROR_CHECKING
- /* send null pointer to directory create to generate an error */
- status = fx_directory_create(FX_NULL, "/A0");
- return_if_fail( status == FX_PTR_ERROR);
-
- /* directory delete */
- status = fx_directory_delete(FX_NULL, "/A0");
- return_if_fail( status == FX_PTR_ERROR);
- #endif /* FX_DISABLE_ERROR_CHECKING */
-
- /* Attempt to create a directory with an invalid name to generate an error */
- status = fx_directory_create(&ram_disk, "");
- return_if_fail( status == FX_INVALID_NAME);
-
- /* Attempt to create a directory with an invalid name to generate an error */
- status = fx_directory_create(&ram_disk, "/A0/error\\error");
- return_if_fail( status == FX_INVALID_PATH);
-
- /* Attempt to create a directory while the media is write protected to generate an error */
- ram_disk.fx_media_driver_write_protect = FX_TRUE;
- status = fx_directory_create(&ram_disk, "/A0");
- return_if_fail( status == FX_WRITE_PROTECT);
-
- /* try to create a directory while the media is write protected to generate an error */
- status = fx_directory_delete(&ram_disk, "/A0");
- return_if_fail( status == FX_WRITE_PROTECT);
- ram_disk.fx_media_driver_write_protect = FX_FALSE;
-
- /* Attempt to create a directory when there is no space to generate an error */
- temp = ram_disk.fx_media_available_clusters;
- ram_disk.fx_media_available_clusters = 0;
- status = fx_directory_create(&ram_disk, "/A0");
- return_if_fail( status == FX_NO_MORE_SPACE);
- ram_disk.fx_media_available_clusters = temp;
- /* Create a series of directories... */
- status = fx_directory_create(&ram_disk, "/A0");
- status += fx_directory_create(&ram_disk, "/B0");
- status += fx_directory_create(&ram_disk, "/C0");
- status += fx_directory_create(&ram_disk, "/D0");
- status += fx_directory_create(&ram_disk, "/E0");
- status += fx_directory_create(&ram_disk, "/F0");
- status += fx_directory_create(&ram_disk, "/G0");
- status += fx_directory_create(&ram_disk, "/H0");
- status += fx_directory_create(&ram_disk, "/I0");
- status += fx_file_create(&ram_disk, "not_a_dir");
- return_if_fail( status == FX_SUCCESS);
- /* Attempt to create the same directory again. */
- status = fx_directory_create(&ram_disk, "/A0");
- return_if_fail( status == FX_ALREADY_CREATED);
- /* Create the next level of sub-directories. */
- status = fx_directory_create(&ram_disk, "/A0/A1");
- status += fx_directory_create(&ram_disk, "/A0/A2");
- status += fx_directory_create(&ram_disk, "/A0/A3");
- status += fx_directory_create(&ram_disk, "/A0/A4");
- status += fx_directory_create(&ram_disk, "/A0/A5");
-
- status += fx_directory_create(&ram_disk, "/B0/B1");
- status += fx_directory_create(&ram_disk, "/B0/B2");
- status += fx_directory_create(&ram_disk, "/B0/B3");
- status += fx_directory_create(&ram_disk, "/B0/B4");
- status += fx_directory_create(&ram_disk, "/B0/B5");
-
- status += fx_directory_create(&ram_disk, "/C0/C1");
- status += fx_directory_create(&ram_disk, "/C0/C2");
- status += fx_directory_create(&ram_disk, "/C0/C3");
- status += fx_directory_create(&ram_disk, "/C0/C4");
- status += fx_directory_create(&ram_disk, "/C0/C5");
- status += fx_directory_create(&ram_disk, "/D0/D1");
- status += fx_directory_create(&ram_disk, "/D0/D2");
- status += fx_directory_create(&ram_disk, "/D0/D3");
- status += fx_directory_create(&ram_disk, "/D0/D4");
- status += fx_directory_create(&ram_disk, "/D0/D5");
- status += fx_directory_create(&ram_disk, "/E0/E1");
- status += fx_directory_create(&ram_disk, "/E0/E2");
- status += fx_directory_create(&ram_disk, "/E0/E3");
- status += fx_directory_create(&ram_disk, "/E0/E4");
- status += fx_directory_create(&ram_disk, "/E0/E5");
- status += fx_directory_create(&ram_disk, "/F0/F1");
- status += fx_directory_create(&ram_disk, "/F0/F2");
- status += fx_directory_create(&ram_disk, "/F0/F3");
- status += fx_directory_create(&ram_disk, "/F0/F4");
- status += fx_directory_create(&ram_disk, "/F0/F5");
-
- status += fx_directory_create(&ram_disk, "/G0/G1");
- status += fx_directory_create(&ram_disk, "/G0/G2");
- status += fx_directory_create(&ram_disk, "/G0/G3");
- status += fx_directory_create(&ram_disk, "/G0/G4");
- status += fx_directory_create(&ram_disk, "/G0/G5");
- status += fx_directory_create(&ram_disk, "/H0/H1");
- status += fx_directory_create(&ram_disk, "/H0/H2");
- status += fx_directory_create(&ram_disk, "/H0/H3");
- status += fx_directory_create(&ram_disk, "/H0/H4");
- status += fx_directory_create(&ram_disk, "/H0/H5");
- status += fx_directory_create(&ram_disk, "/I0/I1");
- status += fx_directory_create(&ram_disk, "/I0/I2");
- status += fx_directory_create(&ram_disk, "/I0/I3");
- status += fx_directory_create(&ram_disk, "/I0/I4");
- status += fx_directory_create(&ram_disk, "/I0/I5");
- return_if_fail( status == FX_SUCCESS);
-
- /* Now create the third level of sub-directories... */
- status = fx_directory_create(&ram_disk, "/A0/A1/A00");
- status += fx_directory_create(&ram_disk, "/B0/B2/B00");
- status += fx_directory_create(&ram_disk, "/C0/C3/C00");
- status += fx_directory_create(&ram_disk, "/D0/D4/D00");
- status += fx_directory_create(&ram_disk, "/E0/E5/E00");
- status += fx_directory_create(&ram_disk, "/F0/F1/F00");
- status += fx_directory_create(&ram_disk, "/G0/G1/G00");
- status += fx_directory_create(&ram_disk, "/H0/H2/H00");
- status += fx_directory_create(&ram_disk, "/I0/I3/I00");
- return_if_fail( status == FX_SUCCESS);
-
- /* Attempt to delete something that is not a directory */
- status = fx_directory_delete(&ram_disk, "not_a_dir");
- return_if_fail( status == FX_NOT_DIRECTORY);
-
- /* Attempt to delete a directory that is not empty */
- status = fx_directory_delete(&ram_disk, "/A0");
- return_if_fail( status == FX_DIR_NOT_EMPTY);
-
- /* Attempt to delete a directory that is read only */
- status = fx_directory_attributes_read(&ram_disk, "/A0/A1/A00", &attributes);
- status += fx_directory_attributes_set(&ram_disk, "/A0/A1/A00", FX_READ_ONLY);
- status += fx_directory_delete(&ram_disk, "/A0/A1/A00");
- return_if_fail( status == FX_WRITE_PROTECT);
- status += fx_directory_attributes_set(&ram_disk, "/A0/A1/A00", attributes);
- /* Now delete all the directories. */
- status = fx_directory_delete(&ram_disk, "/A0/A1/A00");
- status += fx_directory_delete(&ram_disk, "/B0/B2/B00");
- status += fx_directory_delete(&ram_disk, "/C0/C3/C00");
- status += fx_directory_delete(&ram_disk, "/D0/D4/D00");
- status += fx_directory_delete(&ram_disk, "/E0/E5/E00");
- status += fx_directory_delete(&ram_disk, "/F0/F1/F00");
- status += fx_directory_delete(&ram_disk, "/G0/G1/G00");
- status += fx_directory_delete(&ram_disk, "/H0/H2/H00");
- status += fx_directory_delete(&ram_disk, "/I0/I3/I00");
- return_if_fail( status == FX_SUCCESS);
- /* Delete the next level of sub-directories. */
- status += fx_directory_delete(&ram_disk, "/A0/A1");
- status += fx_directory_delete(&ram_disk, "/A0/A2");
- status += fx_directory_delete(&ram_disk, "/A0/A3");
- status += fx_directory_delete(&ram_disk, "/A0/A4");
- status += fx_directory_delete(&ram_disk, "/A0/A5");
-
- status += fx_directory_delete(&ram_disk, "/B0/B1");
- status += fx_directory_delete(&ram_disk, "/B0/B2");
- status += fx_directory_delete(&ram_disk, "/B0/B3");
- status += fx_directory_delete(&ram_disk, "/B0/B4");
- status += fx_directory_delete(&ram_disk, "/B0/B5");
-
- status += fx_directory_delete(&ram_disk, "/C0/C1");
- status += fx_directory_delete(&ram_disk, "/C0/C2");
- status += fx_directory_delete(&ram_disk, "/C0/C3");
- status += fx_directory_delete(&ram_disk, "/C0/C4");
- status += fx_directory_delete(&ram_disk, "/C0/C5");
- status += fx_directory_delete(&ram_disk, "/D0/D1");
- status += fx_directory_delete(&ram_disk, "/D0/D2");
- status += fx_directory_delete(&ram_disk, "/D0/D3");
- status += fx_directory_delete(&ram_disk, "/D0/D4");
- status += fx_directory_delete(&ram_disk, "/D0/D5");
- status += fx_directory_delete(&ram_disk, "/E0/E1");
- status += fx_directory_delete(&ram_disk, "/E0/E2");
- status += fx_directory_delete(&ram_disk, "/E0/E3");
- status += fx_directory_delete(&ram_disk, "/E0/E4");
- status += fx_directory_delete(&ram_disk, "/E0/E5");
- status += fx_directory_delete(&ram_disk, "/F0/F1");
- status += fx_directory_delete(&ram_disk, "/F0/F2");
- status += fx_directory_delete(&ram_disk, "/F0/F3");
- status += fx_directory_delete(&ram_disk, "/F0/F4");
- status += fx_directory_delete(&ram_disk, "/F0/F5");
-
- status += fx_directory_delete(&ram_disk, "/G0/G1");
- status += fx_directory_delete(&ram_disk, "/G0/G2");
- status += fx_directory_delete(&ram_disk, "/G0/G3");
- status += fx_directory_delete(&ram_disk, "/G0/G4");
- status += fx_directory_delete(&ram_disk, "/G0/G5");
- status += fx_directory_delete(&ram_disk, "/H0/H1");
- status += fx_directory_delete(&ram_disk, "/H0/H2");
- status += fx_directory_delete(&ram_disk, "/H0/H3");
- status += fx_directory_delete(&ram_disk, "/H0/H4");
- status += fx_directory_delete(&ram_disk, "/H0/H5");
- status += fx_directory_delete(&ram_disk, "/I0/I1");
- status += fx_directory_delete(&ram_disk, "/I0/I2");
- status += fx_directory_delete(&ram_disk, "/I0/I3");
- status += fx_directory_delete(&ram_disk, "/I0/I4");
- status += fx_directory_delete(&ram_disk, "/I0/I5");
- return_if_fail( status == FX_SUCCESS);
- /* Delete a series of directories... */
- status = fx_directory_delete(&ram_disk, "/A0");
- status += fx_directory_delete(&ram_disk, "/B0");
- status += fx_directory_delete(&ram_disk, "/C0");
- status += fx_directory_delete(&ram_disk, "/D0");
- status += fx_directory_delete(&ram_disk, "/E0");
- status += fx_directory_delete(&ram_disk, "/F0");
- status += fx_directory_delete(&ram_disk, "/G0");
- status += fx_directory_delete(&ram_disk, "/H0");
- status += fx_directory_delete(&ram_disk, "/I0");
- return_if_fail( status == FX_SUCCESS);
- /* Attempt to delete a directory again. */
- status = fx_directory_delete(&ram_disk, "/A0");
- return_if_fail( status == FX_NOT_FOUND);
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- 4096, // Total sectors
- 128, // Sector size
- 2, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- return_if_fail( status == FX_SUCCESS);
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- return_if_fail( status == FX_SUCCESS);
- /* Create a directory name that is too large. */
- for (i = 0; i < FX_MAX_LONG_NAME_LEN+1; i++)
- {
-
- name[i] = 'a';
- }
- name[FX_MAX_LONG_NAME_LEN + 1] = 0;
- /* Attempt to create a directory with too long of a name. */
- status = fx_directory_create(&ram_disk, name);
- return_if_fail( status == FX_INVALID_NAME);
-
- /* Attempt to create a directory with no more clusters. */
- temp = ram_disk.fx_media_total_clusters;
- ram_disk.fx_media_total_clusters = 0;
- status = fx_directory_create(&ram_disk, "sub1");
- ram_disk.fx_media_total_clusters = temp;
- return_if_fail( status == FX_NO_MORE_SPACE);
-
- /* Attempt to create a directory with a FAT read error. */
- _fx_utility_fat_entry_read_error_request = 1;
- status = fx_directory_create(&ram_disk, "sub1");
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Create a subdirectory with a search pointer that must wrap after the allocation. */
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START - 1);
- status = fx_directory_create(&ram_disk, "sub1");
- return_if_fail( status == FX_SUCCESS);
- /* Create a subdirectory with a search pointer that must wrap after the allocation. */
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START - 1);
- status = fx_directory_create(&ram_disk, "sub2");
- return_if_fail( status == FX_SUCCESS);
- /* Create a subdirectory with a search pointer that starts on a non-free cluster. */
- ram_disk.fx_media_cluster_search_start = FX_FAT_ENTRY_START;
- status = fx_directory_create(&ram_disk, "sub3");
- return_if_fail( status == FX_SUCCESS);
- /* Create a subdirectory with a logical sector read error. */
- _fx_utility_logical_sector_read_error_request = 13;
- status = fx_directory_create(&ram_disk, "sub4");
- _fx_utility_logical_sector_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- #ifndef FX_DISABLE_CACHE
- /* Create a subdirectory with a logical flush error. */
- _fx_utility_logical_sector_flush_error_request = 1;
- status = fx_directory_create(&ram_disk, "sub5");
- _fx_utility_logical_sector_flush_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- #endif
- /* Create a subdirectory with an error clearing the additional sectors of a cluster. */
- _fx_ram_driver_io_error_request = 8;
- status = fx_directory_create(&ram_disk, "sub6");
- _fx_ram_driver_io_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Create a subdirectory with an error on writing the FAT entry. */
- _fx_utility_fat_entry_write_error_request = 1;
- status = fx_directory_create(&ram_disk, "sub7");
- _fx_utility_fat_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Create a subdirectory with an error on writing the first director entry. */
- _fx_directory_entry_write_error_request = 1;
- status = fx_directory_create(&ram_disk, "sub8");
- _fx_directory_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Create a subdirectory with an error on writing the second director entry. */
- _fx_directory_entry_write_error_request = 2;
- status = fx_directory_create(&ram_disk, "sub9");
- _fx_directory_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
-
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- 4096, // Total sectors
- 128, // Sector size
- 2, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- return_if_fail( status == FX_SUCCESS);
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- return_if_fail( status == FX_SUCCESS);
-
- /* Create a series of sub-directories... in preparation for our directory delete checking. */
- status = fx_directory_create(&ram_disk, "SUB1");
- status += fx_directory_create(&ram_disk, "SUB2");
- status += fx_directory_create(&ram_disk, "SUB3");
- status += fx_directory_create(&ram_disk, "SUB4");
- status += fx_directory_create(&ram_disk, "SUB5");
- status += fx_directory_create(&ram_disk, "SUB6");
- status += fx_directory_create(&ram_disk, "SUB7");
- status += fx_directory_create(&ram_disk, "SUB8");
- return_if_fail( status == FX_SUCCESS);
- /* Delete a directory but with a FAT read error on the first cluster. */
- _fx_utility_fat_entry_read_error_request = 1;
- status = fx_directory_delete(&ram_disk, "SUB8");
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
-
- /* Delete a directory but with a cluster error - bad small value. */
- _fx_utility_fat_entry_read_error_request = 10001;
- status = fx_directory_delete(&ram_disk, "SUB8");
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_FAT_READ_ERROR);
-
- /* Delete a directory but with a cluster error - bad total clusters. */
- temp = ram_disk.fx_media_total_clusters;
- ram_disk.fx_media_total_clusters = 0;
- status = fx_directory_delete(&ram_disk, "SUB8");
- ram_disk.fx_media_total_clusters = temp;
- return_if_fail( status == FX_FAT_READ_ERROR);
-
- /* Delete a directory but with a cluster error - same value. */
- _fx_utility_fat_entry_read_error_request = 30001;
- status = fx_directory_delete(&ram_disk, "SUB8");
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_FAT_READ_ERROR);
-
- /* Delete a directory but with a directory entry read error. */
- _fx_directory_entry_read_error_request = 1;
- status = fx_directory_delete(&ram_disk, "SUB8");
- _fx_directory_entry_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
-
- /* Delete a directory but with a directory entry write error. */
- _fx_directory_entry_write_error_request = 1;
- status = fx_directory_delete(&ram_disk, "SUB8");
- _fx_directory_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Delete a directory wtih large error request values just to exercise those paths - should be successful. */
- _fx_directory_entry_read_error_request = 10000;
- _fx_directory_entry_write_error_request = 10000;
- status = fx_directory_delete(&ram_disk, "SUB8");
- _fx_directory_entry_read_error_request = 0;
- _fx_directory_entry_write_error_request = 0;
- return_if_fail( status == FX_SUCCESS);
- /* Delete a directory with an error in the freeing of the cluster traversal FAT read. */
- _fx_utility_fat_entry_read_error_request = 2;
- status = fx_directory_delete(&ram_disk, "SUB7");
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Delete a directory but with a cluster error in releasing cluster - bad small value. */
- _fx_utility_fat_entry_read_error_request = 10002;
- status = fx_directory_delete(&ram_disk, "SUB6");
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_FAT_READ_ERROR);
-
- /* Delete a directory but with a cluster error in releasing cluster - bad total clusters. */
- temp = ram_disk.fx_media_total_clusters;
- _fx_utility_fat_entry_read_error_request = 40002;
- status = fx_directory_delete(&ram_disk, "SUB5");
- ram_disk.fx_media_total_clusters = temp;
- return_if_fail( status == FX_FAT_READ_ERROR);
-
- /* Delete a directory but with a cluster error in releasing cluster - same value. */
- _fx_utility_fat_entry_read_error_request = 30002;
- status = fx_directory_delete(&ram_disk, "SUB4");
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_FAT_READ_ERROR);
-
- /* Delete a directory but with a FAT write error in releasing cluster. */
- _fx_utility_fat_entry_write_error_request = 1;
- status = fx_directory_delete(&ram_disk, "SUB3");
- _fx_utility_fat_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 2, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- return_if_fail( status == FX_SUCCESS);
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- return_if_fail( status == FX_SUCCESS);
- /* Create a sub-directory to work from. */
- status = fx_directory_create(&ram_disk, "SUB1");
-
- /* Set the default path here. */
- status += fx_directory_default_set(&ram_disk, "SUB1");
- /* Now try to create some unusual file name to test the internal free search logic. */
- status += fx_file_create(&ram_disk, "..test");
- return_if_fail( status == FX_INVALID_NAME);
- /* Create a name with a character greater than 127. */
- name[0] = 'n';
- name[1] = 'a';
- name[2] = 'm';
- name[3] = 'e';
- name[4] = '\'';
- name[5] = ')';
- name[6] = '(';
- name[7] = '`';
- name[8] = (CHAR) 128;
- name[9] = 0;
-
- status = fx_file_create(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- return_if_fail( status == FX_SUCCESS);
-
- /* Create a name with a bunch of special characters. */
- status = fx_file_create(&ram_disk, "name-a_b}{()'!#$&@^%+,;=[]");
- status += fx_file_open(&ram_disk, &file_2, "name-a_b}{()'!#$&@^%+,;=[]", FX_OPEN_FOR_WRITE);
- return_if_fail( status == FX_SUCCESS);
-
- /* Create a name with an invalid character. */
- name[0] = 'n';
- name[1] = 'a';
- name[2] = 'm';
- name[3] = 'e';
- name[4] = (CHAR) 5;
- name[5] = '\'';
- name[6] = 0;
-
- status = fx_file_create(&ram_disk, name);
- return_if_fail( status == FX_INVALID_NAME);
- /* Create a long file name by position of the dot. */
- status = fx_file_create(&ram_disk, "MYLONGERN.AM");
- status += fx_file_create(&ram_disk, "MY.TXT");
- status += fx_file_open(&ram_disk, &file_3, "MYLONGERN.AM", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_4, "MY.TXT", FX_OPEN_FOR_WRITE);
- return_if_fail( status == FX_SUCCESS);
-
- /* Create a set of very short long file name. */
- status = fx_file_create(&ram_disk, "n");
- status += fx_file_create(&ram_disk, "nW");
- status += fx_file_create(&ram_disk, "nWW");
- status += fx_file_create(&ram_disk, "nWWW");
- status += fx_file_create(&ram_disk, "nWWWW");
- status += fx_file_create(&ram_disk, "nWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_create(&ram_disk, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
- status += fx_file_open(&ram_disk, &file_5, "n", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_6, "nW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_7, "nWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_8, "nWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_9, "nWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_10, "nWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_11, "nWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_12, "nWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_13, "nWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_14, "nWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_15, "nWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_16, "nWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_17, "nWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_18, "nWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_19, "nWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_20, "nWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_21, "nWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_22, "nWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_23, "nWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_24, "nWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_25, "nWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_26, "nWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_27, "nWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_28, "nWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_29, "nWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_30, "nWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_31, "nWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_32, "nWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_33, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_34, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_35, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_36, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_37, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_38, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_39, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_40, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_41, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- status += fx_file_open(&ram_disk, &file_42, "nWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", FX_OPEN_FOR_WRITE);
- return_if_fail( status == FX_SUCCESS);
- /* Build a super long file name that will require additional cluster allocation in the sub-directory. */
- for (i = 0; i < FX_MAX_LONG_NAME_LEN; i++)
- {
- name[i] = 'a';
- }
- name[FX_MAX_LONG_NAME_LEN-2] = 0;
- /* Test the wrap of the FAT table by allocating at the end. */
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_43, name, FX_OPEN_FOR_WRITE);
- return_if_fail( status == FX_SUCCESS);
- /* Change the name to create a new file name. */
- name[FX_MAX_LONG_NAME_LEN-3] = '0';
- /* Test the wrap of the FAT table by allocating at the end. */
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status += fx_file_create(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_44, name, FX_OPEN_FOR_WRITE);
- return_if_fail( status == FX_SUCCESS);
- name[FX_MAX_LONG_NAME_LEN-3] = '1';
- /* Now try to allocate an entry with no more available clusters. */
- temp = ram_disk.fx_media_available_clusters;
- ram_disk.fx_media_available_clusters = 0;
- status += fx_file_create(&ram_disk, name);
- ram_disk.fx_media_available_clusters = temp;
- return_if_fail( status == FX_NO_MORE_SPACE);
- name[FX_MAX_LONG_NAME_LEN-3] = '2';
- /* Now try to allocate an entry with no more total clusters. */
- temp = ram_disk.fx_media_total_clusters;
- _fx_utility_fat_entry_read_error_request = 40064;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
- ram_disk.fx_media_total_clusters = temp;
- return_if_fail( status == FX_NO_MORE_SPACE);
- /* Now try to allocate a new cluster with a FAT read error in fx_directory_free_search. */
- temp = ram_disk.fx_media_total_clusters;
- _fx_utility_fat_entry_read_error_request = 65;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
- ram_disk.fx_media_total_clusters = temp;
- return_if_fail( status == FX_IO_ERROR);
- /* Now try to allocate a new cluster with a logical sector read error in fx_directory_free_search. */
- _fx_utility_logical_sector_read_error_request = 172;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_logical_sector_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- #ifndef FX_DISABLE_CACHE
- /* Now try to allocate a new cluster with a logical sector flush error in fx_directory_free_search. */
- _fx_utility_logical_sector_flush_error_request = 1;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_logical_sector_flush_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- #endif
- /* Now try to allocate a new cluster with a write error when clearing additional sector clusters from fx_directory_free_search. */
- _fx_ram_driver_io_error_request = 91;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_ram_driver_io_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Now try to allocate a new cluster with a write error when writing the FAT link from fx_directory_free_search. */
- _fx_utility_fat_entry_write_error_request = 1;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Now try to allocate a new cluster with a write error when writing the EOF FAT link from fx_directory_free_search. */
- _fx_utility_fat_entry_write_error_request = 3;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Now try to allocate a new cluster with a logical sector write error when writing the new sub-directory sector in fx_directory_free_search. */
- _fx_utility_logical_sector_write_error_request = 1;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_logical_sector_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Now try to allocate a new cluster with a total cluster of 0 in fx_directory_free_search. */
- _fx_utility_fat_entry_read_error_request = 92;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Now try to allocate a new cluster with a bad read value (1) of intial cluster in sub-directory in fx_directory_free_search. */
- _fx_utility_fat_entry_read_error_request = 10095;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_FAT_READ_ERROR);
- /* Now try to allocate a new cluster with a bad read value (same as initial cluster) of intial cluster in sub-directory in fx_directory_free_search. */
- _fx_utility_fat_entry_read_error_request = 30098;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
- return_if_fail( status == FX_FAT_READ_ERROR);
- /* Now try to allocate a new cluster with a bad read value (greater than max) of intial cluster in sub-directory in fx_directory_free_search. */
- temp = ram_disk.fx_media_total_clusters;
- _fx_utility_fat_entry_read_error_request = 40101;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
- ram_disk.fx_media_total_clusters = temp;
- return_if_fail( status == FX_FAT_READ_ERROR);
- /* Now try to allocate a new cluster with an error linking the new cluster chain with the old one in sub-directory in fx_directory_free_search. */
- _fx_utility_fat_entry_write_error_request = 4;
- ram_disk.fx_media_cluster_search_start = ram_disk.fx_media_total_clusters + (FX_FAT_ENTRY_START-1);
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
- /* Now write to each file before we close them. */
- status = fx_file_write(&file_1, "1", 1);
- status += fx_file_write(&file_2, "1", 1);
- status += fx_file_write(&file_3, "1", 1);
- status += fx_file_write(&file_4, "1", 1);
- status += fx_file_write(&file_5, "1", 1);
- status += fx_file_write(&file_6, "1", 1);
- status += fx_file_write(&file_7, "1", 1);
- status += fx_file_write(&file_8, "1", 1);
- status += fx_file_write(&file_9, "1", 1);
- status += fx_file_write(&file_10, "1", 1);
- status += fx_file_write(&file_11, "1", 1);
- status += fx_file_write(&file_12, "1", 1);
- status += fx_file_write(&file_13, "1", 1);
- status += fx_file_write(&file_14, "1", 1);
- status += fx_file_write(&file_15, "1", 1);
- status += fx_file_write(&file_16, "1", 1);
- status += fx_file_write(&file_17, "1", 1);
- status += fx_file_write(&file_18, "1", 1);
- status += fx_file_write(&file_19, "1", 1);
- status += fx_file_write(&file_20, "1", 1);
- status += fx_file_write(&file_21, "1", 1);
- status += fx_file_write(&file_22, "1", 1);
- status += fx_file_write(&file_23, "1", 1);
- status += fx_file_write(&file_24, "1", 1);
- status += fx_file_write(&file_25, "1", 1);
- status += fx_file_write(&file_26, "1", 1);
- status += fx_file_write(&file_27, "1", 1);
- status += fx_file_write(&file_28, "1", 1);
- status += fx_file_write(&file_29, "1", 1);
- status += fx_file_write(&file_30, "1", 1);
- status += fx_file_write(&file_31, "1", 1);
- status += fx_file_write(&file_32, "1", 1);
- status += fx_file_write(&file_33, "1", 1);
- status += fx_file_write(&file_34, "1", 1);
- status += fx_file_write(&file_35, "1", 1);
- status += fx_file_write(&file_36, "1", 1);
- status += fx_file_write(&file_37, "1", 1);
- status += fx_file_write(&file_38, "1", 1);
- status += fx_file_write(&file_39, "1", 1);
- status += fx_file_write(&file_40, "1", 1);
- status += fx_file_write(&file_41, "1", 1);
- status += fx_file_write(&file_42, "1", 1);
- status += fx_file_write(&file_43, "1", 1);
- status += fx_file_write(&file_44, "1", 1);
- status += fx_file_close(&file_1);
- status += fx_file_close(&file_2);
- status += fx_file_close(&file_3);
- status += fx_file_close(&file_4);
- status += fx_file_close(&file_5);
- status += fx_file_close(&file_6);
- status += fx_file_close(&file_7);
- status += fx_file_close(&file_8);
- status += fx_file_close(&file_9);
- status += fx_file_close(&file_10);
- status += fx_file_close(&file_11);
- status += fx_file_close(&file_12);
- status += fx_file_close(&file_13);
- status += fx_file_close(&file_14);
- status += fx_file_close(&file_15);
- status += fx_file_close(&file_16);
- status += fx_file_close(&file_17);
- status += fx_file_close(&file_18);
- status += fx_file_close(&file_19);
- status += fx_file_close(&file_20);
- status += fx_file_close(&file_21);
- status += fx_file_close(&file_22);
- status += fx_file_close(&file_23);
- status += fx_file_close(&file_24);
- status += fx_file_close(&file_25);
- status += fx_file_close(&file_26);
- status += fx_file_close(&file_27);
- status += fx_file_close(&file_28);
- status += fx_file_close(&file_29);
- status += fx_file_close(&file_30);
- status += fx_file_close(&file_31);
- status += fx_file_close(&file_32);
- status += fx_file_close(&file_33);
- status += fx_file_close(&file_34);
- status += fx_file_close(&file_35);
- status += fx_file_close(&file_36);
- status += fx_file_close(&file_37);
- status += fx_file_close(&file_38);
- status += fx_file_close(&file_39);
- status += fx_file_close(&file_40);
- status += fx_file_close(&file_41);
- status += fx_file_close(&file_42);
- status += fx_file_close(&file_43);
- status += fx_file_close(&file_44);
- return_if_fail( status == FX_SUCCESS);
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
-
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- return_if_fail( status == FX_SUCCESS);
- /* Get the first file name, this should be "ntfile" for exercising the NT file name capability. */
- status = fx_directory_first_entry_find(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_next_entry_find(&ram_disk, name);
-
- /* Write to both files, write to them and close them! */
- status += fx_file_write(&file_1, "abcd", 4);
- status += fx_file_write(&file_2, "abcd", 4);
- status += fx_file_close(&file_1);
- status += fx_file_close(&file_2);
- return_if_fail( status == FX_SUCCESS);
-
- /* Now look move to the first sub-directory. */
- status = fx_directory_default_set(&ram_disk, name);
- status += fx_directory_first_entry_find(&ram_disk, name); /* . */
- status += fx_directory_next_entry_find(&ram_disk, name); /* .. */
- status += fx_directory_next_entry_find(&ram_disk, name); /* Too long of a file name. */
- status += fx_file_delete(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name); /* Next too long sub-directory. */
- status += fx_directory_default_set(&ram_disk, name); /* Move to next sub-directory. */
- return_if_fail( status == FX_SUCCESS);
- /* Move back to the root directory. */
- status += fx_directory_default_set(&ram_disk, "\\");
- /* Set an all blank volume name. */
- status += fx_media_volume_set(&ram_disk, " ");
- status += fx_media_volume_get(&ram_disk, volume_name, FX_DIRECTORY_SECTOR);
- status += fx_directory_first_entry_find(&ram_disk, name); /* ntfile */
- status += fx_directory_next_entry_find(&ram_disk, name); /* nt-file~.txt */
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
-
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- return_if_fail( status == FX_SUCCESS);
- /* Get the first shorted file name. */
- status = fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
-
- /* Write to the shorted file. */
- status += fx_file_write(&file_2, "abcd", 4);
- /* Now close the file, which will write the shorted file entry out. */
- _fx_utility_logical_sector_write_error_request = 1;
- status += fx_file_close(&file_2);
- _fx_utility_logical_sector_write_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- return_if_fail( status == FX_SUCCESS);
- /* Get the first shorted file name. */
- status = fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
-
- /* Write to the shorted file. */
- status += fx_file_write(&file_2, "abcd", 4);
- /* Now close the file, which will write the shorted file entry out. */
- temp = ram_disk.fx_media_data_sector_start;
- ram_disk.fx_media_data_sector_start = ram_disk.fx_media_root_sector_start+2;
- status += fx_file_close(&file_2);
- ram_disk.fx_media_data_sector_start = temp;
- return_if_fail( status == FX_FILE_CORRUPT);
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- return_if_fail( status == FX_SUCCESS);
- /* Get the first shorted file name. */
- status = fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Write to the shorted file. */
- status += fx_file_write(&file_2, "abcd", 4);
- /* Now close the file, which will write the shorted file entry out. */
- _fx_utility_logical_sector_read_error_request = 2;
- status += fx_file_close(&file_2);
- _fx_utility_logical_sector_read_error_request = 0;
- return_if_fail( status == FX_IO_ERROR);
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- return_if_fail( status == FX_SUCCESS);
- /* Get the first shorted file name. */
- status = fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_media_flush(&ram_disk);
- status += fx_media_read(&ram_disk, ram_disk.fx_media_root_sector_start+1, buffer);
- buffer[0x40] = 0x1f;
- status += fx_media_write(&ram_disk, ram_disk.fx_media_root_sector_start+1, buffer);
- /* Write to the shorted file. */
- status += fx_file_write(&file_2, "abcd", 4);
- /* Now close the file, which will write the shorted file entry out.... not that the shorted flag is not in the actual directory entry. */
- status += fx_file_close(&file_2);
- return_if_fail( status == FX_SUCCESS);
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- return_if_fail( status == FX_SUCCESS);
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- return_if_fail( status == FX_SUCCESS);
- /* Get the first shorted file name. */
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Switch to this directory. */
- status += fx_directory_default_set(&ram_disk, name);
- status = fx_directory_first_entry_find(&ram_disk, name); /* . */
- status += fx_directory_next_entry_find(&ram_disk, name); /* .. */
- status += fx_directory_next_entry_find(&ram_disk, name); /* shorted long file name! */
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
- /* Write to the shorted file. */
- status += fx_file_write(&file_2, "abcd", 4);
- /* Now close the file, which will write the shorted file entry out. */
- _fx_utility_fat_entry_read_error_request = 1;
- status += fx_file_close(&file_2);
- _fx_utility_fat_entry_read_error_request = 0;
- /* Check the status - should be an error here. */
- if (status != FX_IO_ERROR)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(97);
- }
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(98);
- }
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(99);
- }
- /* Get the first shorted file name. */
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Switch to this directory. */
- status += fx_directory_default_set(&ram_disk, name);
- status = fx_directory_first_entry_find(&ram_disk, name); /* . */
- status += fx_directory_next_entry_find(&ram_disk, name); /* .. */
- status += fx_directory_next_entry_find(&ram_disk, name); /* shorted long file name! */
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
- /* Write to the shorted file. */
- status += fx_file_write(&file_2, "abcd", 4);
- /* Now close the file, which will write the shorted file entry out. */
- _fx_utility_fat_entry_read_error_request = 10001;
- status += fx_file_close(&file_2);
- _fx_utility_fat_entry_read_error_request = 0;
- /* Check the status - should be an error here. */
- if (status != FX_FILE_CORRUPT)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(100);
- }
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(101);
- }
- /* Set the flag to copy the default format to get NT file name, orphan long file name, and super long file names. */
- _fx_ram_driver_copy_default_format = 1;
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- _fx_ram_driver_copy_default_format = 0;
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(102);
- }
- /* Get the first shorted file name. */
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Switch to this directory. */
- status += fx_directory_default_set(&ram_disk, name);
- status = fx_directory_first_entry_find(&ram_disk, name); /* . */
- status += fx_directory_next_entry_find(&ram_disk, name); /* .. */
- status += fx_directory_next_entry_find(&ram_disk, name); /* shorted long file name! */
- status += fx_file_open(&ram_disk, &file_2, name, FX_OPEN_FOR_WRITE);
- /* Write to the shorted file. */
- status += fx_file_write(&file_2, "abcd", 4);
- /* Now close the file, which will write the shorted file entry out. */
- _fx_utility_fat_entry_read_error_request = 20001;
- status += fx_file_close(&file_2);
- _fx_utility_fat_entry_read_error_request = 0;
- /* Check the status - should be an error here. */
- if (status != FX_FILE_CORRUPT)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(103);
- }
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(104);
- }
-
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 2, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(105);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(106);
- }
- /* Build a sub-directory structure to further test diretory entry read. */
- status = fx_directory_create(&ram_disk, "SUB1");
- status += fx_directory_default_set(&ram_disk, "SUB1");
- status += fx_file_create(&ram_disk, "S1_FL1.TXT");
- status += fx_file_create(&ram_disk, "S1_FL2.TXT");
- status += fx_file_create(&ram_disk, "S1_FL3.TXT");
- status += fx_file_create(&ram_disk, "S1_FL4.TXT");
- status += fx_file_create(&ram_disk, "S1_FL5.TXT");
- status += fx_file_create(&ram_disk, "S1_FL6.TXT");
- status += fx_file_create(&ram_disk, "S1_FL7.TXT");
- status += fx_file_create(&ram_disk, "S1_FL8.TXT");
- status += fx_file_create(&ram_disk, "S1_FL9.TXT");
- status += fx_file_create(&ram_disk, "S1_FL10.TXT");
- status += fx_file_create(&ram_disk, "S1_FL11.TXT");
- status += fx_file_create(&ram_disk, "S1_FL12.TXT");
- status += fx_file_create(&ram_disk, "S1_FL13.TXT");
- status += fx_file_create(&ram_disk, "S1_FL14.TXT");
- status += fx_file_create(&ram_disk, "S1_FL15.TXT");
- status += fx_file_create(&ram_disk, "S1_FL16.TXT");
- status += fx_file_create(&ram_disk, "S1_FL17.TXT");
- status += fx_file_create(&ram_disk, "S1_FL18.TXT");
- status += fx_file_create(&ram_disk, "S1_FL19.TXT");
- status += fx_file_create(&ram_disk, "S1_FL20.TXT");
- status += fx_file_create(&ram_disk, "S1_FL21.TXT");
- status += fx_file_create(&ram_disk, "S1_FL22.TXT");
- status += fx_file_create(&ram_disk, "S1_FL23.TXT");
- status += fx_file_create(&ram_disk, "S1_FL24.TXT");
- status += fx_file_create(&ram_disk, "S1_FL25.TXT");
- status += fx_file_create(&ram_disk, "S1_FL26.TXT");
- status += fx_file_create(&ram_disk, "S1_FL27.TXT");
- status += fx_file_create(&ram_disk, "S1_FL28.TXT");
- status += fx_file_create(&ram_disk, "S1_FL29.TXT");
- status += fx_file_create(&ram_disk, "S1_FL30.TXT");
- status += fx_file_create(&ram_disk, "S1_FL31.TXT");
- status += fx_file_create(&ram_disk, "S1_FL32.TXT");
-
- /* Now taverse the directory tree and open files. */
- status += fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- ram_disk.fx_media_default_path.fx_path_directory.fx_dir_entry_last_search_relative_cluster = 100;
- status += fx_directory_next_entry_find(&ram_disk, name);
- ram_disk.fx_media_default_path.fx_path_directory.fx_dir_entry_last_search_log_sector = 1000;
- status += fx_directory_next_entry_find(&ram_disk, name);
- ram_disk.fx_media_default_path.fx_path_directory.fx_dir_entry_last_search_byte_offset = 10000;
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(107);
- }
- /* Now go back to the beginning of the directory. */
- status += fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
-
- /* Search with I/O read error. */
- ram_disk.fx_media_default_path.fx_path_directory.fx_dir_entry_last_search_cluster = 0; /* Cause cluster traversal. */
- _fx_utility_fat_entry_read_error_request = 1;
- status += fx_directory_next_entry_find(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_IO_ERROR)
- {
- printf("ERROR!\n");
- test_control_return(108);
- }
-
- /* Search with bad FAT error - too small. */
- ram_disk.fx_media_default_path.fx_path_directory.fx_dir_entry_last_search_cluster = 0; /* Cause cluster traversal. */
- _fx_utility_fat_entry_read_error_request = 10001;
- status = fx_directory_next_entry_find(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(109);
- }
-
- /* Search with bad FAT error - too small. */
- ram_disk.fx_media_default_path.fx_path_directory.fx_dir_entry_last_search_cluster = 0; /* Cause cluster traversal. */
- _fx_utility_fat_entry_read_error_request = 20001;
- status = fx_directory_next_entry_find(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(110);
- }
- /* Corrupt the media to test zero divisor checking. */
- ram_disk.fx_media_bytes_per_sector = 0;
- status = fx_directory_next_entry_find(&ram_disk, name);
- /* Determine if the expected error is present. */
- if (status != FX_MEDIA_INVALID)
- {
- printf("ERROR!\n");
- test_control_return(110);
- }
- ram_disk.fx_media_bytes_per_sector = 128;
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Move back to the root directory. */
- status = fx_directory_default_set(&ram_disk, "\\");
- status += fx_unicode_file_create(&ram_disk, my_unicode_name, 15, (CHAR *)buffer);
- status += fx_unicode_file_create(&ram_disk, my_unicode_name1, 15, (CHAR *)buffer);
- status += fx_file_create(&ram_disk, name);
-
- /* Set the search to the beginning of the root directory. */
- status += fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(111);
- }
-
- /* Now generate an error on the root directory size. */
- temp = ram_disk.fx_media_root_sectors;
- ram_disk.fx_media_root_sectors = 1;
- status = fx_directory_next_entry_find(&ram_disk, name);
- ram_disk.fx_media_root_sectors = temp;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(112);
- }
- /* Now generate an error with a logical sector read error. */
- _fx_utility_logical_sector_read_error_request = 5;
- status = fx_directory_next_entry_find(&ram_disk, name);
- _fx_utility_logical_sector_read_error_request = 0;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_IO_ERROR)
- {
- printf("ERROR!\n");
- test_control_return(113);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(114);
- }
-
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 32, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(115);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(116);
- }
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Create a sub-directory. */
- status = fx_directory_create(&ram_disk, "SUB1");
- status += fx_directory_default_set(&ram_disk, "SUB1");
- status += fx_file_create(&ram_disk, name);
- status += fx_directory_first_entry_find(&ram_disk, (CHAR *)buffer);
- status += fx_directory_next_entry_find(&ram_disk, (CHAR *)buffer);
-
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(117);
- }
-
- /* Read the first entry, but with a FAT entry error. */
- _fx_utility_fat_entry_read_error_request = 1;
- status = fx_directory_next_entry_find(&ram_disk, (CHAR *)buffer);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_IO_ERROR)
- {
- printf("ERROR!\n");
- test_control_return(118);
- }
- /* Read the first entry, but with a FAT entry error - too small. */
- _fx_utility_fat_entry_read_error_request = 10001;
- status = fx_directory_next_entry_find(&ram_disk, (CHAR *)buffer);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(119);
- }
-
- /* Read the first entry, but with a FAT entry error - too big. */
- _fx_utility_fat_entry_read_error_request = 20001;
- status = fx_directory_next_entry_find(&ram_disk, (CHAR *)buffer);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Determine if the expected I/O error is present. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(120);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(121);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 512, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(122);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(123);
- }
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Create a large file name in the root directory. */
- _fx_utility_logical_sector_write_error_request = 22;
- status = fx_file_create(&ram_disk, name);
- _fx_utility_logical_sector_write_error_request = 0;
-
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
-
- /* Determine if have the expected I/O error. */
- if (status != FX_IO_ERROR)
- {
- printf("ERROR!\n");
- test_control_return(124);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(125);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 512, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(126);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(127);
- }
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Create a large file name in the root directory. */
- _fx_utility_logical_sector_read_error_request = 45;
- status = fx_file_create(&ram_disk, name);
- _fx_utility_logical_sector_read_error_request = 0;
-
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
-
- /* Determine if have the expected I/O error. */
- if (status != FX_IO_ERROR)
- {
- printf("ERROR!\n");
- test_control_return(128);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(129);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 512, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(130);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(131);
- }
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Create a large file name in the root directory. */
- temp = ram_disk.fx_media_data_sector_start;
- ram_disk.fx_media_data_sector_start = ram_disk.fx_media_root_sector_start+1;
- status = fx_file_create(&ram_disk, name);
- ram_disk.fx_media_data_sector_start = temp;
-
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
-
- /* Determine if have the expected error. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(132);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(133);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 512, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(134);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(135);
- }
- /* Create a sub-directory so we can generate errors writing to the sub-directory file entry. */
- status = fx_directory_create(&ram_disk, "SUB1");
- status += fx_directory_default_set(&ram_disk, "SUB1");
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(136);
- }
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Create a large file name in the sub-directory with a FAT entry read error. */
- _fx_utility_fat_entry_read_error_request = 14;
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
-
- /* Determine if have the expected error. */
- if (status != FX_IO_ERROR)
- {
- printf("ERROR!\n");
- test_control_return(137);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(138);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 512, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(139);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(140);
- }
- /* Create a sub-directory so we can generate errors writing to the sub-directory file entry. */
- status = fx_directory_create(&ram_disk, "SUB1");
- status += fx_directory_default_set(&ram_disk, "SUB1");
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(141);
- }
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Create a large file name in the sub-directory with a FAT entry read error. */
- _fx_utility_fat_entry_read_error_request = 10014;
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
-
- /* Determine if have the expected error. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(142);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(143);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 512, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(144);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(145);
- }
- /* Create a sub-directory so we can generate errors writing to the sub-directory file entry. */
- status = fx_directory_create(&ram_disk, "SUB1");
- status += fx_directory_default_set(&ram_disk, "SUB1");
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(146);
- }
- /* Build a large file name. */
- for (i = 0; i < 255; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
- /* Create a large file name in the sub-directory with a FAT entry read error. */
- _fx_utility_fat_entry_read_error_request = 20014;
- status = fx_file_create(&ram_disk, name);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Setup an I/O error on the first logical sectory write of the directory entry. */
- status += fx_media_flush(&ram_disk);
-
- /* Determine if have the expected error. */
- if (status != FX_FILE_CORRUPT)
- {
- printf("ERROR!\n");
- test_control_return(147);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(148);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 10000, // Directory Entries
- 0, // Hidden sectors
- 64000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(149);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(150);
- }
-
- /* Create a file name that execises the short name with a 0xE5 and a dot less than the eighth character. */
- status = fx_file_create(&ram_disk, "a.a");
- status += fx_media_flush(&ram_disk);
- status += fx_media_read(&ram_disk, ram_disk.fx_media_root_sector_start, buffer);
- buffer[0x20] = 0x8f;
- buffer[0x21] = 0xe5;
- buffer[0x22] = '.';
- buffer[0x23] = 'a';
- buffer[0x24] = '~';
- status += fx_media_write(&ram_disk, ram_disk.fx_media_root_sector_start, buffer);
- status += fx_media_flush(&ram_disk);
- status += fx_directory_short_name_get(&ram_disk, "a.a", name);
- status += fx_file_open(&ram_disk, &file_1, "a.a", FX_OPEN_FOR_WRITE);
- status += fx_file_write(&file_1, "a", 1);
- file_1.fx_file_dir_entry.fx_dir_entry_short_name[0] = (CHAR)0xE5;
- status += fx_media_flush(&ram_disk);
- status += fx_file_close(&file_1);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(151);
- }
- /* Create some files to test the logic in fx_directory_entry_read */
- status = fx_file_create(&ram_disk, "a");
- status += fx_directory_short_name_get(&ram_disk, "a", name);
- status += fx_file_create(&ram_disk, "aa");
- status += fx_directory_short_name_get(&ram_disk, "aa", name);
- status += fx_file_create(&ram_disk, "aaa");
- status += fx_directory_short_name_get(&ram_disk, "aaa", name);
- status += fx_file_create(&ram_disk, "aaaa");
- status += fx_directory_short_name_get(&ram_disk, "aaaa", name);
- status += fx_file_create(&ram_disk, "aaaaa");
- status += fx_directory_short_name_get(&ram_disk, "aaaaa", name);
- status += fx_file_create(&ram_disk, "aaaaaa");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaa", name);
- status += fx_file_create(&ram_disk, "aaaaaaa");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaaa", name);
- status += fx_file_create(&ram_disk, "aaaaaaaa");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaaaa", name);
- status += fx_file_create(&ram_disk, "aaaaaaaa.a");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaaaa.a", name);
- status += fx_file_create(&ram_disk, "aaaaaaaa.aa");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaaaa.aa", name);
- status += fx_file_create(&ram_disk, "aaaaaaaa.aaa");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaaaa.aaa", name);
- status += fx_file_create(&ram_disk, "a.");
- status += fx_directory_short_name_get(&ram_disk, "a.", name);
- status += fx_file_create(&ram_disk, "aa.");
- status += fx_directory_short_name_get(&ram_disk, "aa.", name);
- status += fx_file_create(&ram_disk, "aaa.");
- status += fx_directory_short_name_get(&ram_disk, "aaa.", name);
- status += fx_file_create(&ram_disk, "aaaa.");
- status += fx_directory_short_name_get(&ram_disk, "aaaa.", name);
- status += fx_file_create(&ram_disk, "aaaaa.");
- status += fx_directory_short_name_get(&ram_disk, "aaaaa.", name);
- status += fx_file_create(&ram_disk, "aaaaaa.");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaa.", name);
- status += fx_file_create(&ram_disk, "aaaaaaa.");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaaa.", name);
- status += fx_file_create(&ram_disk, "aaaaaaaa.");
- status += fx_directory_short_name_get(&ram_disk, "aaaaaaaa.", name);
- status += fx_file_delete(&ram_disk, "aaaaaa.");
- status += fx_file_delete(&ram_disk, "aaaaaaa.");
- status += fx_file_delete(&ram_disk, "aaaaaaaa.");
-
- /* Create a name with an 0xe5 in the front. */
- name[0] = (CHAR)0xE5;
- name[1] = 'a';
- name[2] = 'b';
- name[3] = '.';
- name[4] = 't';
- name[5] = 'x';
- name[6] = 't';
- name[7] = 0;
- status += fx_file_create(&ram_disk, name);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_file_write(&file_1, "1", 1);
- status += fx_file_close(&file_1);
- status += fx_file_create(&ram_disk, "abcdefgh.txt");
- status += fx_directory_short_name_get(&ram_disk, "abcdefgh.txt", (CHAR *)buffer);
- status += fx_file_open(&ram_disk, &file_1, "abcdefgh.txt", FX_OPEN_FOR_WRITE);
- status += fx_file_write(&file_1, "1", 1);
- status += fx_file_close(&file_1);
- #if EXTENDED_NAME_MANGLE_TEST
- name[0] = 'a';
- name[1] = 'B';
- name[2] = 'C';
- name[3] = 'D';
- name[4] = 'E';
- name[5] = 'F';
- name[6] = 'G';
- name[7] = '0';
- name[8] = '0';
- name[9] = '0';
- name[10] = '0';
- name[11] = 0;
- for (i = 0; i < 3; i++)
- {
- name[7] = '0' + i;
- for (j = 0; j < 10; j++)
- {
-
- name[8] = '0' + j;
-
- for (k = 0; k < 10; k++)
- {
- name[9] = '0' + k;
-
- for (l = 0; l < 10; l++)
- {
- if (status)
- break;
- name[10] = '0' + l;
- status += fx_file_create(&ram_disk, name);
- if (status)
- break;
- status += fx_directory_short_name_get(&ram_disk, name, buffer);
- if (status)
- break;
- }
- }
- }
- }
- #endif
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(152);
- }
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(153);
- }
-
-
- /* Test corner cases on fx_directory_search. */
-
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 256, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(154);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(155);
- }
-
- /* Build a long directory structure. */
- status = fx_directory_create(&ram_disk, "/sub-directory_depth_00001");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010");
- status += fx_directory_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010/sub-directory_depth_00011");
- status += fx_file_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010/sub-directory_depth_00011/file1.txt");
- status += fx_file_open(&ram_disk, &file_1, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010/sub-directory_depth_00011/file1.txt", FX_OPEN_FOR_WRITE);
- /* Now create an invalid path by using a file as a directory entry. */
- status += fx_file_create(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010/sub-directory_depth_00011/file1.txt/baddir");
- /* Determine if the test was successful. */
- if (status != FX_INVALID_PATH)
- {
- printf("ERROR!\n");
- test_control_return(156);
- }
-
- status = fx_file_create(&ram_disk, "/sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010/sub-directory_depth_00011/file2.txt");
- status += fx_file_open(&ram_disk, &file_2, "/sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010/sub-directory_depth_00011/file2.txt", FX_OPEN_FOR_WRITE);
- status += fx_directory_default_set(&ram_disk, "sub-directory_depth_00001/sub-directory_depth_00002/sub-directory_depth_00003/sub-directory_depth_00004/sub-directory_depth_00005/sub-directory_depth_00006/sub-directory_depth_00007/sub-directory_depth_00008/sub-directory_depth_00009/sub-directory_depth_00010/sub-directory_depth_00011");
- status += fx_directory_first_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Close the media. */
- status += fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(157);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 256, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(158);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(159);
- }
- /* Build a long sub-directory name... This name will be too long to cache in fx_directory_search. */
- for (i = 0; i < FX_MAX_LONG_NAME_LEN; i++)
- {
- name[i] = 'a';
- }
- name[0] = '/';
- name[256] = 0;
-
- status = fx_directory_create(&ram_disk, name);
-
- name[256] = '/';
- name[257] = 'f';
- name[258] = 'i';
- name[259] = 'l';
- name[260] = 'e';
- name[261] = 0;
-
- status += fx_file_create(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, &name[1], FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, &name[1], FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_file_delete(&ram_disk, name);
- /* Build a perfect fit long sub-directory name and file name... This name will fit exactly into the fx_directory_search cache. */
- for (i = 0; i < FX_MAX_LONG_NAME_LEN; i++)
- {
- name[i] = 'a';
- }
- name[0] = '/';
- name[250] = 0;
-
- status += fx_directory_create(&ram_disk, name);
-
- name[250] = '/';
- name[251] = 'f';
- name[252] = 'i';
- name[253] = 'l';
- name[254] = 'e';
- name[255] = 0;
-
- status = fx_file_create(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, &name[1], FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, &name[1], FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status = fx_file_delete(&ram_disk, name);
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(160);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 256, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(161);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(162);
- }
- /* Build a perfect fit long sub-directory name and file name... This name will fit exactly into the fx_directory_search cache. */
- for (i = 0; i < FX_MAX_LONG_NAME_LEN; i++)
- {
- name[i] = 'a';
- }
- name[0] = '/';
- name[255] = 0;
- status += fx_directory_create(&ram_disk, name);
-
-
- name[253] = 0;
-
- status += fx_directory_create(&ram_disk, name);
-
- name[253] = '/';
- name[254] = 'a';
- name[255] = 0;
-
- status = fx_file_create(&ram_disk, name);
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_file_close(&file_1);
- /* Setup info for direct call to directory search. */
- dir_entry.fx_dir_entry_name = ram_disk.fx_media_name_buffer + FX_MAX_LONG_NAME_LEN;
- search_directory.fx_dir_entry_name = ram_disk.fx_media_name_buffer + FX_MAX_LONG_NAME_LEN * 2;
- dir_entry.fx_dir_entry_short_name[0] = 0;
- search_directory.fx_dir_entry_short_name[0] = 0;
- /* Lets make the name bigger than the maximun name. */
- name[255] = 'a';
- name[256] = 'a';
- name[257] = 'a';
- name[258] = 'a';
- name[259] = 0;
- _fx_directory_search(&ram_disk, name, &dir_entry, &search_directory, &name_ptr);
-
-
- /* Set the name back to the original size. */
- name[255] = 0;
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_file_close(&file_1);
- /* Now make the name long again to test relative, no path. */
- name[255] = 'a';
-
- /* Now let's perform a maximum relative search. */
- _fx_directory_search(&ram_disk, &name[1], &dir_entry, &search_directory, &name_ptr);
-
- /* Now lets set a path and test that out. */
- name[253] = 0;
- status += fx_directory_default_set(&ram_disk, name);
-
- /* Now set the name back to the original size. */
- name[253] = '/';
- name[255] = 0;
-
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_file_close(&file_1);
- /* Now make the name long again to test relative, with path. */
- name[255] = 'a';
-
- /* Now let's perform a maximum relative search. */
- _fx_directory_search(&ram_disk, &name[1], &dir_entry, &search_directory, &name_ptr);
- /* Now lets set a path, modify the found path and test that out. */
- name[253] = 'a';
- name[254] = 'a';
- name[255] = 0;
- status += fx_directory_default_set(&ram_disk, name);
-
- /* Now set the name back to the original size. */
- name[253] = '/';
- name[255] = 0;
-
- status += fx_file_open(&ram_disk, &file_1, name, FX_OPEN_FOR_WRITE);
- status += fx_directory_short_name_get(&ram_disk, name, (CHAR *)buffer);
- status += fx_file_close(&file_1);
- /* Test the maximum size of the default path lookup. */
- for (i = 0; i < 256; i++)
- {
- ram_disk.fx_media_last_found_name[i] = ram_disk.fx_media_default_path.fx_path_name_buffer[i];
- }
- ram_disk.fx_media_last_found_name[0] = '/';
- name[255] = 'a';
- name[256] = 0;
- /* Now let's perform a maximum relative search. */
- _fx_directory_search(&ram_disk, &name[1], &dir_entry, &search_directory, &name_ptr);
-
- /* Now let's setup a directory search with a NULL path, a maximum found file name, and alternate directory separators. */
- ram_disk.fx_media_default_path.fx_path_name_buffer[0] = 0;
- strcpy(&ram_disk.fx_media_last_found_name[0], "\\abc\\def\\ghi\\abc");
- for (i = 0; i < 256; i++)
- {
- ram_disk.fx_media_last_found_file_name[i] = 'a';
- ram_disk.fx_media_last_found_directory.fx_dir_entry_name[i] = 'a';
- }
- ram_disk.fx_media_last_found_file_name[255] = 0;
- ram_disk.fx_media_last_found_directory.fx_dir_entry_name[255] = 0;
- ram_disk.fx_media_last_found_directory_valid = FX_TRUE;
- _fx_directory_search(&ram_disk, "abc\\def\\ghi\\abc", &dir_entry, &search_directory, &name_ptr);
- /* Now let's setup a directory search with a NULL path, a medium sized found file name, and alternate directory separators. */
- ram_disk.fx_media_default_path.fx_path_name_buffer[0] = 0;
- strcpy(&ram_disk.fx_media_last_found_name[0], "\\abc\\def\\ghi\\abc");
- for (i = 0; i < 256; i++)
- {
- ram_disk.fx_media_last_found_file_name[i] = 'a';
- ram_disk.fx_media_last_found_directory.fx_dir_entry_name[i] = 'a';
- }
- ram_disk.fx_media_last_found_file_name[255] = 0;
- ram_disk.fx_media_last_found_directory.fx_dir_entry_name[25] = 0;
- ram_disk.fx_media_last_found_directory_valid = FX_TRUE;
- _fx_directory_search(&ram_disk, "abc\\def\\ghi\\abc", &dir_entry, &search_directory, &name_ptr);
-
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(163);
- }
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 256, // Directory Entries
- 0, // Hidden sectors
- 14000, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- /* Determine if the format had an error. */
- if (status)
- {
- printf("ERROR!\n");
- test_control_return(164);
- }
-
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(165);
- }
- /* Create a directory path. */
- status = fx_directory_create(&ram_disk, "/abc");
- status += fx_directory_create(&ram_disk, "/abc/def");
- status += fx_directory_create(&ram_disk, "/abc/def/ghi");
- status += fx_directory_create(&ram_disk, "/abc/def/ghi/jkl");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file2.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file3.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file4.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file5.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file6.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file7.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file8.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file9.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file10.txt");
- status += fx_file_create(&ram_disk, "/abc/def/ghi/jkl/file11.txt");
- status += fx_directory_default_set(&ram_disk, "/abc");
- status += fx_directory_first_entry_find(&ram_disk, name);
-
- /* Now open the file to get it into the search cache. */
- status += fx_file_open(&ram_disk, &file_1, "/abc/def/ghi/jkl/file.txt", FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, "/abc/def/ghi/jkl/file.txt", FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_file_open(&ram_disk, &file_1, "def/ghi/jkl/file.txt", FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_directory_default_set(&ram_disk, "/");
- status += fx_file_open(&ram_disk, &file_1, "abc/def/ghi/jkl/file.txt", FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_1);
- status += fx_directory_next_entry_find(&ram_disk, name);
- /* Now test for FAT read errors. */
- _fx_utility_fat_entry_read_error_request = 1;
- status += fx_file_open(&ram_disk, &file_2, "abc/def/ghi/jkl/file2.txt", FX_OPEN_FOR_WRITE);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Check the status... should be an I/O error at this point. */
- if (status != FX_IO_ERROR)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(166);
- }
-
- /* Now test a FAT entry value that is too small. */
- _fx_utility_fat_entry_read_error_request = 10001;
- status = fx_file_open(&ram_disk, &file_2, "abc/def/ghi/jkl/file2.txt", FX_OPEN_FOR_WRITE);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Check the status... should be a FAT read error. */
- if (status != FX_FAT_READ_ERROR)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(167);
- }
-
- /* Now test a FAT entry value that is too large. */
- temp = ram_disk.fx_media_total_clusters;
- _fx_utility_fat_entry_read_error_request = 40001;
- status = fx_file_open(&ram_disk, &file_2, "abc/def/ghi/jkl/file2.txt", FX_OPEN_FOR_WRITE);
- _fx_utility_fat_entry_read_error_request = 0;
- ram_disk.fx_media_total_clusters = temp;
-
- /* Check the status... should be a FAT read error. */
- if (status != FX_FAT_READ_ERROR)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(168);
- }
-
- /* Now test a FAT entry value that is the same as the cluster itself. */
- _fx_utility_fat_entry_read_error_request = 30001;
- status = fx_file_open(&ram_disk, &file_2, "abc/def/ghi/jkl/file2.txt", FX_OPEN_FOR_WRITE);
- _fx_utility_fat_entry_read_error_request = 0;
-
- /* Check the status... should be a FAT read error. */
- if (status != FX_FAT_READ_ERROR)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(169);
- }
-
- /* Now perform a good open. */
- status = fx_file_open(&ram_disk, &file_2, "abc/def/ghi/jkl/file2.txt", FX_OPEN_FOR_WRITE);
- status += fx_file_close(&file_2);
-
- /* Check the status. */
- if (status != FX_SUCCESS)
- {
- /* Error, return error code. */
- printf("ERROR!\n");
- test_control_return(166);
- }
-
- /* Setup info for direct call to directory search. */
- dir_entry.fx_dir_entry_name = ram_disk.fx_media_name_buffer + FX_MAX_LONG_NAME_LEN;
- search_directory.fx_dir_entry_name = ram_disk.fx_media_name_buffer + FX_MAX_LONG_NAME_LEN * 2;
- dir_entry.fx_dir_entry_short_name[0] = 0;
- search_directory.fx_dir_entry_short_name[0] = 0;
- /* Lets perform a search that from the root directory. */
- _fx_directory_search(&ram_disk, "/abc/..", &dir_entry, &search_directory, &name_ptr);
-
- /* Now setup a maximum default path. */
- for (i = 0; i < FX_MAX_LAST_NAME_LEN; i++)
- {
- name[i] = 'a';
- }
- name[255] = 0;
-
- /* Create a sub-directory of maximum lenght. */
- status = fx_directory_create(&ram_disk, name);
-
- /* Set the default path to this name. */
- status += fx_directory_default_set(&ram_disk, name);
-
- /* Create a file in the sub-directory path. */
- status += fx_file_create(&ram_disk, "file1.txt");
-
- /* Open the file to test the directory search cache name build. */
- status += fx_file_open(&ram_disk, &file_1, "file1.txt", FX_OPEN_FOR_WRITE);
-
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(167);
- }
-
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(168);
- }
- /* Test for https://github.com/azure-rtos/filex/issues/26 */
- /* Format the media. This needs to be done before opening it! */
- status = fx_media_format(&ram_disk,
- _fx_ram_driver, // Driver entry
- ram_disk_memory, // RAM disk memory pointer
- cache_buffer, // Media buffer pointer
- CACHE_SIZE, // Media buffer size
- "MY_RAM_DISK", // Volume Name
- 1, // Number of FATs
- 4, // Directory Entries
- 0, // Hidden sectors
- 128, // Total sectors
- 128, // Sector size
- 1, // Sectors per cluster
- 1, // Heads
- 1); // Sectors per track
- return_if_fail( status == FX_SUCCESS);
- /* Open the ram_disk. */
- status = fx_media_open(&ram_disk, "RAM DISK", _fx_ram_driver, ram_disk_memory, cache_buffer, 128);
- return_if_fail( status == FX_SUCCESS);
- FX_FILE my_file;
- ULONG available_clusters;
- uint8_t buff[128];
- int num_of_files = 0;
- char dummy_file_path[DIR_PATH_SIZE + 3];
- memcpy(dummy_file_path, DIR_PATH, DIR_PATH_SIZE);
- /* Create a file called TEST.TXT.*/
- status += fx_directory_create(&ram_disk, "/MYDIR");
- status += fx_directory_create(&ram_disk, "MYDIR/MYDIR1");
- status += fx_directory_create(&ram_disk, "MYDIR/MYDIR1/MYDIR2");
- status += fx_directory_create(&ram_disk, "MYDIR/MYDIR1/MYDIR2/MYDIR3");
- return_if_fail( status == FX_SUCCESS);
-
- status = fx_file_create(&ram_disk, "MYDIR/MYDIR1/MYDIR2/MYDIR3/TEST.TXT");
- return_if_fail( status == FX_SUCCESS);
- available_clusters = ram_disk.fx_media_available_clusters;
- /*
- * Ensure there is no spare space in the cluster used for the directory
- */
- dummy_file_path[sizeof(DIR_PATH) - 1] = 'A';
- dummy_file_path[sizeof(DIR_PATH)] = '\0';
- for (num_of_files = 0; available_clusters == ram_disk.fx_media_available_clusters; num_of_files ++)
- {
- dummy_file_path[sizeof(DIR_PATH) - 1] ++;
- status = fx_file_create(&ram_disk, dummy_file_path);
- return_if_fail( status == FX_SUCCESS);
- }
- // remove the file that allocated new cluster
- status = fx_file_delete(&ram_disk, dummy_file_path);
- return_if_fail( status == FX_SUCCESS);
- /* Open the test file. */
- status = fx_file_open(&ram_disk, &my_file, "MYDIR/MYDIR1/MYDIR2/MYDIR3/TEST.TXT", FX_OPEN_FOR_WRITE);
- return_if_fail( status == FX_SUCCESS);
- available_clusters = ram_disk.fx_media_available_clusters;
- for (int i = 0; i < available_clusters - 1; i++)
- {
- /* Write a one cluster size to the test file. */
- status = fx_file_write(&my_file, buff, sizeof(buff));
- return_if_fail( status == FX_SUCCESS);
- }
- /* The dir entry should be created on new cluster */
- status =fx_file_rename(&ram_disk, "MYDIR/MYDIR1/MYDIR2/MYDIR3/TEST.TXT", "MYDIR/MYDIR1/MYDIR2/MYDIR3/TEST_RENAME.TXT");
- return_if_fail (status == FX_SUCCESS);
- return_if_fail(ram_disk.fx_media_available_clusters == 0);
- /* Close the media. */
- status = fx_media_close(&ram_disk);
- /* Determine if the test was successful. */
- if (status != FX_SUCCESS)
- {
- printf("ERROR!\n");
- test_control_return(169);
- }
- else
- {
- printf("SUCCESS!\n");
- test_control_return(0);
- }
- }
|