Link to home
Start Free TrialLog in
Avatar of decentswati
decentswati

asked on

change file to directories and vice versa

Hi,
It's funny to think or say but i have a question in my mind,
is there any way to change the files to directories or vice versa by some way.like changing the in its property of
drwxr--r-- to -rwxr--r--
if it could be please suggest
ASKER CERTIFIED SOLUTION
Avatar of alikoank
alikoank

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of decentswati
decentswati

ASKER

Hi de2Zotjes,
really I think the way is to change the property of directory file to make it a regular file.give me the suggestion so that I can try it.OfCourse there is no reason or need to do that but knowing the thing will make concepts clear.Help me.

bye
decentswati
Make sure you have libext2fs on your system (ldconfig -p|grep ext2fs) It is part of the e2fsprogs collection.

After that it would be something like:
(this is pseudo-code!)

#include <ext2fs.h>

main () {
err_code = ext2fs_read_inode(fs,inode_num,&inode)
inode.i_mode = inode.i_mode | LINUX_S_IFDIR
ext2fs_write_inode(fs,inode_num, &inode)
}

Not even close to a working program but these are the funtions you would need to use.

Again: you most likely WILL f*ck up your complete file system! dump before you try this.