November 21, 2024, 04:36:57 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Linux File System Structure Questions  (Read 10808 times)

Offline mohit.saha

  • Linux Noob !
  • *
  • Posts: 10
Linux File System Structure Questions
« on: March 28, 2008, 10:44:07 AM »
Can any one answer me upon the following questions:

1)   Can a file be on more than one block group?
2)   Does every block group have unique Inode table?
3)   Where the file names are stored, if not in the inode?
4)   Other than data block what all e2compr changes with respect to the physical structure of ext2 file system?
5)   How the physical structure of ext2 and ext3 file system differs?
6)   What changes the journalling bring about in the physical structure of ext3 file system?

Thanking all in anticipation....  ???

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Re: Linux File System Structure Questions
« Reply #1 on: October 29, 2009, 04:41:29 PM »
1)   Can a file be on more than one block group?
Yes, if that file is big enough.

2)   Does every block group have unique Inode table?
Correction on my previous comment. It has to be unique inode number. This is very level bits and bytes of disks with inodes pointing to each of them.

3)   Where the file names are stored, if not in the inode?
In the directory that will link to the inodes.

4)   Other than data block what all e2compr changes with respect to the physical structure of ext2 file system?
Not sure how to answer this.

5)   How the physical structure of ext2 and ext3 file system differs?
No answer to this

6)   What changes the journalling bring about in the physical structure of ext3 file system?
No answer to this

http://www.nongnu.org/ext2-doc/ext2.html
« Last Edit: October 30, 2009, 03:17:37 AM by dragoncity99 »

Offline dharshini123

  • New Member
  • Posts: 1
Difference between cp and mv linux command
« Reply #2 on: May 27, 2010, 06:24:57 AM »
Hi,

  I am facing one problem only with mv command not with cp command. I have a test program

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <fcntl.h>
#include <errno.h>

int sync_file(char *file)
{
    FILE *fp=NULL;
    int fd;

    printf("file is %s\n",file);
    fp = fopen(file, "r");
    if(!fp)
        return -1;

    fd = fileno(fp);
    fflush(fp);
    fsync(fd);
    ioctl (fd, BLKFLSBUF, 0);
    fclose(fp);
    return 0;

}

int main()
{
    int len=0;
    FILE *fp = NULL;
    char buf[1024];
    char *fname = "/etc/test.conf";
    char fname_tmp[129] = "";


    len = sprintf(buf, "%s\n", "Newly added Line is there");

    snprintf(fname_tmp, 128, "%s.tmp", fname);

    if( (fp = fopen(fname_tmp,"a")) == NULL )
        printf(" ERROR: open(), error - %s\n",strerror(errno));

    fprintf(fp,"%s",buf);
    fflush(fp);

    fsync(fileno(fp));
    fclose(fp);
    system("cp -f /etc/test.conf.tmp /etc/test.conf");
   // system("mv -f /etc/test.conf.tmp /etc/test.conf");
    sync_file(fname);
    return 0;
}

Here i am opening a tmp file for writing. Then i am copying/moving for original file. Then i do a fflush, fsync(), ioctl() to the original file. Then i run this binary in linux machine(ext2 file system, 2.6.23.5 kernel) after that immediately  power off the machine. Then power on machine, the file is disappeared or written data lost or file gets corrupted if i move the tmp file to the original file. And there is a no problem if i copy the tmp file to original file. So i want to know the difference between the cp and mv command. Can you please give me suggestion on it?

Thanks,
Indira.

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Re: Linux File System Structure Questions
« Reply #3 on: July 23, 2010, 11:19:15 AM »
In LInux, all datas are not committed to the disks. They could be still in the buffer (in the memory). They are routingly flushed  to the disks when the buffer is full. So, If you purposely power off the machine abnormally all those uncommitted into the disk will dissapear, or even left partially hanging there...