The module os.walk lists all of the files within the "path" directory, including those within subdirectories of "path". In your case, this would include files not just under "C:" but also "C:\windows", "C:\users", etc. Which is what you expect.However your code is listing just the filenames, checks to see if each one is an MXD, and if so then joins the mxd filename to "C:\". So if there's an MXD called "C:\users\map.mxd", your code is ultimately converting that path to "C:\map.mxd". Fortunately os.walk also includes the full directory path of each file (named "root" in your code). Try changing "path" to "root" in this line:fullPath = os.path.join(root,filename)
So the full code would look like this:
import arcpy.mapping as mapping, os
path = r"C:"
f = open('filename_here.txt','w')
for root,dirs,files in os.walk(path):
for filename in files:
basename, extension = os.path.splitext(filename)
if extension == ".mxd":
fullPath = os.path.join(root,filename)
mxd = mapping.MapDocument(fullPath)
f.write("MXD: " + filename + "\n")
brknList = mapping.ListBrokenDataSources(mxd)
for brknItem in brknList:
f.write("\t" + brknItem.name + "\n")
f.close()