136dc
![]() |
|
|
|
|
|||||||
| General General questions about the FreeBSD operating system. Ask here if your question does not fit elsewhere. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
When I input a vi command, I often didn't finish the file name and edited a directory instead. Although I haven't saved the edit yet, it's very close for many times. It makes me very worried. So, I'm wondering what I can about it if I edited a directory accidentally. For example, if I run
Code:
#vi /var/db/mysql/ |
|
#2
|
|||
|
|||
|
I don't think you could ever destroy the filesystem this way. And vi can't "edit directories".
All you should normally get when trying to edit a directory is this: Code:
Warning: <some directory> is not a regular file Code:
Error: <some directory>: Is a directory.
__________________
May the source be with you! |
|
#3
|
|||
|
|||
|
Never got the warning. Did this many times, the only step I haven't done is saving.
|
|
#4
|
||||
|
||||
|
What FreeBSD version? Are you using nvi or vim? Both should barf out similar warnings about this.
A directory is really just a special type of file, as you can see with: $ od -c directory_hereEven if you somehow managed to "edit" the directory, the files would still be there, presumably accessible directly by inode. (If they didn't have any other hard links, you'd have to do some work to access them again, though.) More to the point: use your shell's tab completion, and slow down when you're editing. Give your eyes and brain a few seconds to engage before you start typing.
__________________
"Do Not Engage in Useless Activity" --Miyamoto Musashi |
|
#6
|
|||
|
|||
|
Quote:
Quote:
Many thanks for all your help! |
|
#8
|
|||
|
|||
|
Thanks for the info, fluca1978, that's a relief.
|
|
#9
|
||||
|
||||
|
It's sorta read-only. By default, Emacs' dired allows the user to carry out file/directory operations (move, copy, delete, etc.), but you have to activated wdired mode to edit the directory in the same way you'd edit a text file -- although even then, you can only operate on the filenames, and not all the permissions, filesize information, etc.
__________________
http://sdf.org/ -- SDF Public Access Unix System, Est. 1987 http://gopher.floodgap.com/overbite/relevance.html -- Why is Gopher Still Relevant? |
|
#10
|
|||
|
|||
|
I always thought directories could not be written with normal write operations.
open(2), ERRORS section: Code:
[EISDIR] The named file is a directory, and the arguments spec‐
ify it is to be modified.
Last edited by xibo; July 22nd, 2012 at 09:25. Reason: use CODE, not QUOTE |
|
#11
|
|||
|
|||
|
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cannot edit in nanoBSD | razi91 | Installing & Upgrading | 2 | February 22nd, 2012 12:32 |
| Which file do I edit? | Desreguard | X.Org | 2 | August 19th, 2011 07:20 |
| [Solved] Can't edit my own posting! | bsdmonk | Off-Topic | 12 | April 7th, 2010 23:07 |
| How can I edit my own Profile Picture? | Sundj | Off-Topic | 20 | March 26th, 2010 11:33 |
| [Solved] Cannot edit /etc/rc.conf | IIjkII | General | 8 | August 12th, 2009 11:17 |