/////////////////////////////////////////////////////////////////////////-*-C-*- 
//
// Copyright (c) 2002, 2003 Xilinx, Inc.  All rights reserved.
//
// Xilinx, Inc.
//
// XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 
// COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
// ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 
// STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
// IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 
// FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.  
// XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 
// THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 
// ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 
// FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Description : 
//  Test program to create a new RAM based file system and use it
//          mb-gcc $OPTIONS testmfs.c  mfs_filesys.c mfs_filesys_util.c -o testmfs
//
// $Id: testmfs.c,v 1.1 2003/01/10 19:15:10 mohan Exp $
//
////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "xilmfs.h"

char *fs = (char *)0xffe00000; /* base address of SRAM */

int main(int argc, char *argv[]) {

  int numbytes;
  char buffer[4];
  int fd;
  
  numbytes = 10 *sizeof(struct mfs_file_block);

  mfs_init_fs(numbytes, fs, MFSINIT_NEW);
  mfs_create_dir("dir1");
  mfs_change_dir("dir1");
  mfs_create_dir("dir1_1");
  mfs_change_dir("dir1_1");
  mfs_create_dir("dir1_1_1");
  fd = mfs_file_open("file1", MFS_MODE_CREATE);
  mfs_file_write(fd, "abcd", 4);
  mfs_file_close(fd);
  mfs_change_dir("..");
  fd = mfs_file_open("file2", MFS_MODE_CREATE);
  mfs_file_write(fd, "efgh", 4);
  mfs_file_close(fd);
  fd = mfs_file_open("file2",  MFS_MODE_READ);
  if (mfs_file_read(fd, buffer, 4) != 4) {
    print("1");
  }
  else  {
    print("0");
  }
  mfs_file_close(fd);
  mfs_change_dir("..");
  mfs_change_dir("..");
  mfs_ls_r(-1);
}


 
