-3

In summary, if I use ls -l it yields something for a directory like...

drwxr-xr-x

and the reported error for a directory with files in it, is it shows as a standard file and ls -l yields...

-rwxr-xr-x

My goal is to find a way to manually change file type from "-" to "d" on existing files or directories.

My first post here. For days I've been trying to find a way to change file type for a file in Apple OSX (BSD Unix). This may be so much easier than I am making it. Original problem was the tool that comes with OSX to check your hard disk is Disk Utility (DU) and it shows file permissions errors it cannot repair. Sometimes it is a couple hundred. Most are the kind where a directory file is showing as a standard file, and should be changed to directory. If I navigate there with Terminal, the expected files are in the directory. These errors may occur from Passive Hack attack over the last year. One fix that works is wipe and install OSX. It is a new good HDD.

The first method I had planned to use, is to find file header information on the disk sectors with a hex editor like R-Studio for Mac, and simply do my hex math if necessary and change the data. It will take extensive time to learn enough R-Studio to do this. Plus I think I need a map of how BSD Unix lays information onto HDD sectors, so that I can locate the bits that label file as directory or standard file, or pipe, or socket. The map would resemble this but with logical data layout for a BSD file. https://en.wikipedia.org/wiki/Advanced_Format

Been to several forums and Apple support and R-Studio support. Stopped short of paying $99 to join Apple Developers to get this information. I think it is open anyway since BSD Unix.

Other tools I explored were Apple's IDE Xcode, Unix dd command, and emacs. Because I'm new with Unix it takes me a very long time, and I still see no method to accomplish this. In the tutorial for Xcode, it mentions that recommended tools show up when hovering over menu icons. When I hovered over the file type it showed emacs, but after reading, I think it means whether it is a text file or executable file type. Not directory and such.

At this point I'm back to looking for the logical file layout that BSD Unix puts onto the disk sectors, and then use R-Studio.

Any ideas?

1 Answers1

1

That is impossible to change. Files cannot be changed into directories and vice versa. It is not just some flag that can be changed. If this is some kind of corruption, your best bet is to run an fsck on the filesystem.

Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36
  • Thanks @Ryan. I don't want to do it at my whim. I want to do it to make it correctly reflect what it is. It is simply a piece of data that is reporting incorrectly. Please see original post. If I go to the directory that DU reports is a standard file, it is actually a directory that I can "cd" into and "ls" the files in it. File header is saying it is a standard file and not a directory. So DU is apparently correct with the error reporting. Also want to mention I'm looking into xxd man page. – Chris_top_he_r Oct 07 '15 at 01:45
  • Sorry I messed up. This was supposed to post in the Unix & Linux forum. – Chris_top_he_r Oct 07 '15 at 02:40
  • What if you "ls -ld "? Will it show it as a directory? Have you tried fsck? – Ryan Babchishin Oct 07 '15 at 02:56
  • I must have a setting wrong, as I thought I'd be notified in email of posts and wasn't. Just happened to check in. Someone told me about dirent and inode yesterday. Great place to start reading man pages. Haven't tried ls -ld or fsck yet. I have a lot to study now. Thanks for your help. – Chris_top_he_r Oct 09 '15 at 04:56