歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

Linux文件系統omfs文件的讀寫

為了研究omfs文件系統是如何進行文件的write操作,我在應用層寫了個小程序:

相關閱讀:

Linux文件系統omfs的目錄創建和刪除 http://www.linuxidc.com/Linux/2012-02/54025.htm 

Linux文件系統omfs的目錄創建和刪除 http://www.linuxidc.com/Linux/2012-02/54025.htm

Linux文件系統omfs的普通文件創建和刪除 http://www.linuxidc.com/Linux/2012-02/54026.htm

#include <stdio.h>

#include <stdlib.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <unistd.h>

#include <fcntl.h>

#include <errno.h>

 

Void main()

{

         Int I;

         Char w[16384];

         Int fd;

         Int count;

         Fd = open(“/mnt/point1/cccc”,O_RDWR);

         Perror(“open”);

         For( I = 0; I < 16384; i++)

         {

                   W[i] = 0x99;

}

Lseek(fd,0,SEEK_END);

Count = write(fd,w,16384);

Perror(“program”);

Printf(“count: %d\n”, count);

 

}

 

這個程序的目的主要在於寫入/mnt/point1/目錄下的某個文件,而我們的omfs文件系統就掛載在該目錄下。

 

目前該目錄下的情況如下:

ls –ali

接下來我們對cccc這個文件寫入16384個字節,每個字節都是0x99.

Copyright © Linux教程網 All Rights Reserved