{"id":36883,"date":"2004-12-27T07:00:00","date_gmt":"2004-12-27T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2004\/12\/27\/you-can-create-an-infinitely-recursive-directory-tree\/"},"modified":"2004-12-27T07:00:00","modified_gmt":"2004-12-27T07:00:00","slug":"you-can-create-an-infinitely-recursive-directory-tree","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20041227-00\/?p=36883","title":{"rendered":"You can create an infinitely recursive directory tree"},"content":{"rendered":"<p><P>\nIt is possible to create an infinitely recursive directory tree.\nThis throws many recursive directory-traversal functions into disarray.\nHere&#8217;s how you do it.  (Note: Requires NTFS.)\n<\/P>\n<P>\nCreate a directory in the root of your C: drive, call it C:\\C,\nfor lack of a more creative name.\nRight-click My Computer and select Manage.\nclick on the Disk Management snap-in.\n<\/P>\n<P>\nFrom the Disk Management snap-in, right-click the C drive\nand select &#8220;Change Drive Letter and Paths&#8230;&#8221;.\n<\/P>\n<P>\nFrom the &#8220;Change Drive Letter and Paths for C:&#8221; dialog,\nclick &#8220;Add&#8221;, then where it says\n&#8220;Mount in the following empty NTFS folder&#8221;,\nenter &#8220;C:\\C&#8221;.  Click OK.\n<\/P>\n<P>\nCongratulations, you just created an infinitely recursive directory.\n<\/P>\n<PRE>\nC:\\&gt; dir<\/p>\n<p> Volume in drive has no label\n Volume Serial Number is A035-E01D<\/p>\n<p> Directory of C:\\<\/p>\n<p>08\/19\/2001  08:43 PM                 0 AUTOEXEC.BAT\n12\/23\/2004  09:43 PM    &lt;JUNCTION&gt;     C\n05\/05\/2001  04:09 PM                 0 CONFIG.SYS\n12\/16\/2001  04:34 PM    &lt;DIR&gt;          Documents and Settings\n08\/10\/2004  12:00 AM    &lt;DIR&gt;          Program Files\n08\/28\/2004  01:08 PM    &lt;DIR&gt;          WINDOWS\n               2 File(s)              0 bytes\n               4 Dir(s)   2,602,899,968 bytes free<\/p>\n<p>C:\\&gt; dir C:\\C<\/p>\n<p> Volume in drive has no label\n Volume Serial Number is A035-E01D<\/p>\n<p> Directory of C:\\C<\/p>\n<p>08\/19\/2001  08:43 PM                 0 AUTOEXEC.BAT\n12\/23\/2004  09:43 PM    &lt;JUNCTION&gt;     C\n05\/05\/2001  04:09 PM                 0 CONFIG.SYS\n12\/16\/2001  04:34 PM    &lt;DIR&gt;          Documents and Settings\n08\/10\/2004  12:00 AM    &lt;DIR&gt;          Program Files\n08\/28\/2004  01:08 PM    &lt;DIR&gt;          WINDOWS\n               2 File(s)              0 bytes\n               4 Dir(s)   2,602,899,968 bytes free<\/p>\n<p>C:\\&gt; dir C:\\C\\C\\C\\C\\C\\C<\/p>\n<p> Volume in drive has no label\n Volume Serial Number is A035-E01D<\/p>\n<p> Directory of C:\\C\\C\\C\\C\\C\\C<\/p>\n<p>08\/19\/2001  08:43 PM                 0 AUTOEXEC.BAT\n12\/23\/2004  09:43 PM    &lt;JUNCTION&gt;     C\n05\/05\/2001  04:09 PM                 0 CONFIG.SYS\n12\/16\/2001  04:34 PM    &lt;DIR&gt;          Documents and Settings\n08\/10\/2004  12:00 AM    &lt;DIR&gt;          Program Files\n08\/28\/2004  01:08 PM    &lt;DIR&gt;          WINDOWS\n               2 File(s)              0 bytes\n               4 Dir(s)   2,602,899,968 bytes free\n<\/PRE>\n<P>\nGo ahead and add as many &#8220;\\C&#8221;s as you like.  You&#8217;ll just get your own\nC drive back again.\n<\/P>\n<P>\nOkay, now that you&#8217;ve had your fun,\ngo back to the\n&#8220;Change Drive Letter and Paths for C:&#8221; dialog and Remove\nthe &#8220;C:\\C&#8221; entry.\nDo this before you create some real havoc.\n<\/P>\n<P>\nNow imagine what happens if you had tried a recursive treecopy\nfrom that mysterious C:\\C directory.\nOr if you ran a program that did some sort of recursive operation\nstarting from C:\\C, like, say, trying to add up the sizes of all\nthe files in it.\n<\/P>\n<P>\nIf you&#8217;re writing such a program, you need to be aware of reparse\npoints (that thing that shows up as <CODE>&lt;JUNCTION&gt;<\/CODE> in the\ndirectory listing).\nYou can identify them because their file attributes include the\n<CODE>FILE_ATTRIBUTE_REPARSE_POINT<\/CODE> flag.\nOf course, what you do when you find one of these is up to you.\nI&#8217;m just warning you that these strange things exist and if you\naren&#8217;t careful, your program can go into an infinite loop.\n<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is possible to create an infinitely recursive directory tree. This throws many recursive directory-traversal functions into disarray. Here&#8217;s how you do it. (Note: Requires NTFS.) Create a directory in the root of your C: drive, call it C:\\C, for lack of a more creative name. Right-click My Computer and select Manage. click on the [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-36883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>It is possible to create an infinitely recursive directory tree. This throws many recursive directory-traversal functions into disarray. Here&#8217;s how you do it. (Note: Requires NTFS.) Create a directory in the root of your C: drive, call it C:\\C, for lack of a more creative name. Right-click My Computer and select Manage. click on the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/36883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=36883"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/36883\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=36883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=36883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=36883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}