On Wed, Jun 23, 1999 at 09:49:27AM +0300, Petri Kaukasoina wrote:
> You can try it yourself to see if it works or not with kernels today:
> ...
Actually that might not be a valid test because file2 was not fsynced. It's
hard to remember what was done a year ago... But I used a program similar to
the attached one to create and fsync the test file. So this might be valid
now.
1. gcc -o testprog testprog.c
2. mkdir testdir
3. chattr +S testdir
4. cd testdir
5. killall -KILL update
6. sync
7. ../testprog
8. switch off the power
9. switch on the power
10. after fsck look for the file "testfile" in the directories testdir and
lost+found (under the mount point of the file system)
If the chattr trick worked you would have "testfile" in "testdir". Otherwise
you would find it in lost+found.
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main()
{
int fd;
char *message = "testing\n";
if ((fd=open("testfile",O_CREAT|O_RDWR|O_EXCL,0666))==-1) perror("open");
if (write(fd,message,strlen(message))==-1) perror("write");
if (fsync(fd)==-1) perror("fsync");
if (close(fd)==-1) perror("close");
return 0;
}