예제 #1
0
파일: init.c 프로젝트: dakk/Misc
int main()
{
	//printf("Init (%s)\n", VERSION);
	//printf("Probing all devices: %d probed.\n", device_probe_all(BUS_PCI));
	
	//printf("Mounting / with tarfs\n");
	vfs_mount("ram", "/", "tarfs", NULL);

	//printf("Mounting /dev with devfs\n");
	vfs_mount("ram", "/dev", "devfs", NULL);


	for(;;);
}
예제 #2
0
파일: serialdev.c 프로젝트: Razi007/toaruos
void serial_mount_devices() {

	fs_node_t * ttyS0 = serial_device_create(SERIAL_PORT_A);
	vfs_mount("/dev/ttyS0", ttyS0);

	fs_node_t * ttyS1 = serial_device_create(SERIAL_PORT_B);
	vfs_mount("/dev/ttyS1", ttyS1);

	fs_node_t * ttyS2 = serial_device_create(SERIAL_PORT_C);
	vfs_mount("/dev/ttyS2", ttyS2);

	fs_node_t * ttyS3 = serial_device_create(SERIAL_PORT_D);
	vfs_mount("/dev/ttyS3", ttyS3);

}
예제 #3
0
파일: vfs.c 프로젝트: Rotte/osm-k
int vfs_mount_fs(gbd_t *disk, char *volumename)
{
    fs_t *filesystem;
    int ret;

    filesystem = filesystems_try_all(disk);
    if(filesystem == NULL) {
        kprintf("VFS: No filesystem was found on block device 0x%8.8x\n",
                disk->device->io_address);
        return VFS_NO_SUCH_FS;
    }

    if(volumename==NULL)
        volumename=filesystem->volume_name;

    if(volumename[0] == '\0') {
        kprintf("VFS: Unknown filesystem volume name,"
                " skipping mounting\n");
        filesystem->unmount(filesystem);
        return VFS_INVALID_PARAMS;
    }

    if((ret=vfs_mount(filesystem, volumename)) == VFS_OK) {
        kprintf("VFS: Mounted filesystem volume [%s]\n",
                volumename);
    } else {
        kprintf("VFS: Mounting of volume [%s] failed\n",
                volumename);
        filesystem->unmount(filesystem);
    }

    return ret;
}
예제 #4
0
파일: vfs.c 프로젝트: CasperBHansen/OSM
void vfs_mount_all(void)
{
    int i;
    device_t *dev;
    
    fs_t * pipe = pipe_init();
    vfs_mount(pipe, pipe->volume_name);
    
    for(i=0; i<CONFIG_MAX_FILESYSTEMS; i++) {
        dev = device_get(YAMS_TYPECODE_DISK, i);
        if(dev == NULL) {
            /* No more disks. */
            return;
        } else {
            gbd_t *gbd;
            gbd = (gbd_t *) dev->generic_device;

            if(gbd == NULL) {
                kprintf("VFS: Warning, invalid disk driver detected, "
                        "skipping\n");
                continue;
            }

            vfs_mount_fs(gbd, NULL);
        }
    }
}
예제 #5
0
파일: grub.c 프로젝트: jgraef/meinOS
/**
 * Runs grub modules
 *  @param modules List of GRUB modules
 */
int init_run_grub_modules(pid_t *modules) {
  size_t i;

  signal(SIGUSR1,sigusr1_handler);

  for (i=0;modules[i]!=0;i++) {
    char *name = getname(modules[i]);

    proc_run(modules[i]);

    if (init_wait_grub_module()==-1) {
      dbgmsg("init: Process %s does not respond. initialization failed!\n",name);
      return -1;
    }

    if (strcmp(name,"iso9660")==0) {
      // Initial mount of boot device
      vfs_mount(BOOT_FS,BOOT_MP,BOOT_DEV,BOOT_RO);
    }

    free(name);
  }

  return 0;
}
예제 #6
0
파일: main.c 프로젝트: JamesLinus/levos6
void do_mount() {
    for(int i = 0; i < get_num_of_devices(); i++)
        vfs_mount("/", device_get(i));

    if (!vfs_root_mounted())
        panic("unable to mount root directory\n");
}
예제 #7
0
/*Mount a FS*/
void mount(int i) { 
  char *args = ( char *)i;
  struct device *device ;
  int nr = 0;
  char output[MAX_PATH+1],*ptr,*str;
  char pathname[MAX_PATH+1];
  int dev_number=-1;
  /*max 3 args*/
  char *argv[3] = { NULL,FAT12_NAME,NULL };

  if(! args ) {
  out_usage:
        printf("usage: mount mountpoint FS DEVICE\n");
	goto out;
  }
  /*get the args: mountpoint,FS,devicename*/
  strncpy(output,args,sizeof(output)-1);
  ptr = output;
  while(ptr && *ptr) { 
    /*skip leading spaces*/
    while(*ptr && isspace(*ptr) ) ++ptr;
    if( ! *ptr )
      break;

    if( nr >= 3 ) {
      goto out_usage;
    }
    str = strchr(ptr,' ');
    if(str) {
      *str++ = 0;
    }
    /*store the arg*/
    argv[nr++] = ptr; 
    ptr = str;
  }
  if(!argv[0] ) { 
    printf("No mount point specified...\n");
    goto out_usage;
  }
  if(! argv[2] ) { 
    dev_number = MKDEV(FDC_BLKDEV_MAJOR_NR,0);
  } else {
    device = get_dev_by_name(argv[2]);
    if(!device) { 
      printf("Device %s not found...\n",argv[2]);
      goto out;
    }
    dev_number = device->dev;
  }
  trim_file_separator(argv[0],pathname,sizeof(pathname)-1);
  /*Special check for MOUNTS of / via shell.Not allowed*/
  if(!strcmp(pathname,FILE_SEPARATOR_STR) ) {
    printf("cannot mount already mounted \"%s\", again as it cannot be unmounted...\n",FILE_SEPARATOR_STR);
    goto out;
  }
  vfs_mount(pathname,argv[1],dev_number);
 out:;
}
예제 #8
0
파일: rd.c 프로젝트: mduft/tachyon3
static void rd_init() {
    /* find and protect initial ram disc */
    rd = mboot_find_rd();

    if(rd != NULL) {
        debug("rd found at %p, %d files\n", rd, rd->num_files);
        vfs_mount(path_create("/rd", &kheap), rd_ops);
    }
}
예제 #9
0
static int _MsApi_BrickTerminator_Recover_Reserve ()
{
    MS_BOOL bNeedReburn = TRUE;
    U32 u32PathSize = 0;
    const char* BOOT_RECOVER_BRICK_RESERVE_VOLUME = "brickreserve";
    const char* BOOT_RECOVER_BRICK_BACKUP_VOLUME = "brickbackup";
    const char* BOOT_RECOVER_BRICK_RESERVE_FILE = "/.ready";
    const char* BOOT_RECOVER_BRICK_BACKUP_FILE = "/MstarUpgrade_reserve.bin";
    if(0 == vfs_mount((char*)BOOT_RECOVER_BRICK_RESERVE_VOLUME))
    {
        u32PathSize = vfs_getsize((char*)BOOT_RECOVER_BRICK_RESERVE_FILE);
        if(0 < u32PathSize)
        {
            bNeedReburn = FALSE;
            UBOOT_DEBUG("%s: u32PathSize: %u, at %d\n", __func__, u32PathSize, __LINE__); // DBG
        }
        else // TODO: remove after debug
        {
            UBOOT_ERROR("%s: ERROR: vfs_getsize failed, at %d\n", __func__, __LINE__);
        }
    }
    if(TRUE == bNeedReburn)
    {
        char cmd[CMD_BUF] = {};
        vfs_umount();
        if(0 == vfs_mount((char*)BOOT_RECOVER_BRICK_BACKUP_VOLUME))
        {
            sprintf(cmd, "bstar %s", BOOT_RECOVER_BRICK_BACKUP_FILE);
            UBOOT_ERROR("%s: ERROR: VFS failed, at %d\n", __func__, __LINE__);
            UBOOT_DEBUG("%s: DO BRICK RESERVE RECOVER, at %d\n", __func__, __LINE__);
            //NOTE: do partition recover
            run_command(cmd, 0);
            vfs_umount();
        }
    }
    else
    {
        UBOOT_DEBUG("%s: '%s' is ok, no need to re-burn, at %d\n", __func__, BOOT_RECOVER_BRICK_RESERVE_VOLUME, __LINE__);
        vfs_umount();
    }
    return 0;
}
예제 #10
0
파일: main.c 프로젝트: CoryXie/BarrelfishOS
static int mount(const char *path, const char *uri)
{
    char *apath = vfs_path_mkabsolute(cwd, path);
    errval_t err = vfs_mount(apath, uri);
    free(apath);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "in vfs_mount %s %s", path, uri);
        return 1;
    }
    return 0;
}
예제 #11
0
int vfs_init( void )
{
	// initilize Device File System driver
	dfs_init();
	// mount the DFS
	vfs_mount( NULL, "/amos/device/", DFS_TYPE );

	// initilize FAT File System driver
	fat_init();

	return SUCCESS;
}
예제 #12
0
파일: kmain.c 프로젝트: Detegr/tapiOS
void kmain(struct multiboot* b, uint32_t magic)
{
	hide_cursor();
	cls();
	setup_gdt();
	setup_idt();
	if(b->mods_count == 1)
	{
		uint32_t mods_start_addr=*(uint32_t*)(b->mods_addr);
		uint32_t mods_end_addr=*(uint32_t*)(b->mods_addr + 4);
		if(((uint32_t)&__kernel_end - KERNEL_VMA) < mods_end_addr) kernel_end_addr=(mods_end_addr & 0xFFFFF000) + 0x1000;
	}
	setup_bitmap();
	setup_vmm();
	setup_pic();
	setup_tasking();
	setup_process_tree();
	set_timer_freq(100);

	pci_init();
	setup_network();

	b=(struct multiboot*)((uint8_t*)b+KERNEL_VMA);
	uint32_t mods_addr=*(uint32_t*)(b->mods_addr + KERNEL_VMA) + KERNEL_VMA;
	root_fs=ext2_fs_init((uint8_t*)mods_addr);
	struct inode *devfs=devfs_init();
	struct inode *devfs_root=vfs_search((struct inode*)root_fs, "/dev");
	if(devfs_root)
	{
		vfs_mount(devfs, devfs_root);
		register_tty_driver();
		register_kbd_driver();
		register_rtl8139_driver();
	}
	else kprintf("Could not mount /dev, no such directory\n");

	kprintf("\n%@Welcome to tapiOS!%@\n\n", 0x05, 0x07, b->mods_count, 0x03);

	struct inode *node=vfs_search((struct inode*)root_fs, "/bin/init");
	if(node)
	{
		struct file *init=vfs_open(node, NULL, O_RDONLY);
		uint8_t *init_mem=kmalloc(node->size);
		int read=vfs_read(init, init_mem, node->size);
		vaddr_t entrypoint=init_elf_get_entry_point(init_mem);
		setup_initial_process(entrypoint);
	}
	else kprintf("Init not found\n");
	__asm__ volatile("hltloop: hlt; jmp hltloop");

	PANIC();
}
예제 #13
0
파일: fat_test.c 프로젝트: Karamax/arrakis
int main(int argc, char *argv[])
{
    vfs_init();
    vfs_mkdir("/fat");
    
    errval_t err = vfs_mount("/fat", "fat32://0+0");
    if (err_is_fail(err)) {
        USER_PANIC_ERR(err, "vfs_fat_mount failed");
    }

    walk_dir("/fat");

    return 0;
}
예제 #14
0
파일: vfs.c 프로젝트: timsjostrand/lodge
void vfs_init(const char *mount_path)
{
	for (int i = 0; i < VFS_MAX_NUM_FILES; i++)
	{
		vfs_global->file_table[i].name[0] = '\0';
		vfs_global->file_table[i].size = 0;
		vfs_global->file_table[i].data = 0;
		vfs_global->file_table[i].read_callbacks = 0;
	}

	if (mount_path != NULL) {
		vfs_mount(mount_path);
	}
}
예제 #15
0
파일: serial.c 프로젝트: klange/ponyos
static int serial_mount_devices(void) {

	fs_node_t * ttyS0 = serial_device_create(SERIAL_PORT_A);
	vfs_mount("/dev/ttyS0", ttyS0);

	fs_node_t * ttyS1 = serial_device_create(SERIAL_PORT_B);
	vfs_mount("/dev/ttyS1", ttyS1);

	fs_node_t * ttyS2 = serial_device_create(SERIAL_PORT_C);
	vfs_mount("/dev/ttyS2", ttyS2);

	fs_node_t * ttyS3 = serial_device_create(SERIAL_PORT_D);
	vfs_mount("/dev/ttyS3", ttyS3);

	char * c;
	if ((c = args_value("logtoserial"))) {
		debug_file = ttyS0;
		debug_level = atoi(c);
		debug_print(NOTICE, "Serial logging enabled at level %d.", debug_level);
	}


	return 0;
}
예제 #16
0
파일: vfs.c 프로젝트: CoryXie/BarrelfishOS
/**
 * \brief Initialise the VFS library
 *
 * This call initialises the VFS library. It must be called prior to any
 * other VFS functions being used. It doesn't need to be a constructor
 * We call it explicitly..
 */
void vfs_init(void)
{
    assert(mounts == NULL);
    errval_t err;

    // init libc glue
    vfs_fopen_init();

    // mount ramfs on root, as a sensible default setup for the time being
    err = vfs_mount("/", "ramfs://");
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "error mounting ramfs");
        // continue anyway...
    }
}
예제 #17
0
static int cmd_vfs_mount(struct vmm_chardev *cdev, 
			 const char *dev, const char *path)
{
	int rc;
	bool found;
	int fd, num, count;
	struct vmm_blockdev *bdev;
	struct filesystem *fs;

	bdev = vmm_blockdev_find(dev);
	if (!bdev) {
		vmm_cprintf(cdev, "Block device %s not found\n", dev);
		return VMM_ENODEV;
	}

	if (strcmp(path, "/") != 0) {
		fd = vfs_opendir(path);
		if (fd < 0) {
			vmm_cprintf(cdev, "Directory %s not found\n", path);
			return fd;
		} else {
			vfs_closedir(fd);
		}
	}

	found = FALSE;
	count = vfs_filesystem_count();
	vmm_cprintf(cdev, "Trying:");
	for (num = 0; num < count; num++) {
		fs = vfs_filesystem_get(num);
		vmm_cprintf(cdev, " %s", fs->name);
		rc = vfs_mount(path, fs->name, dev, MOUNT_RW);
		if (!rc) {
			found = TRUE;
			vmm_cprintf(cdev, "\n"); 
			break;
		}
	}

	if (!found) {
		vmm_cprintf(cdev, "\nMount failed\n");
		return VMM_ENOSYS;
	}

	vmm_cprintf(cdev, "Mounted %s using %s at %s\n", dev, fs->name, path);

	return VMM_OK;
}
예제 #18
0
파일: fish.c 프로젝트: CoryXie/BarrelfishOS
static int mount(int argc, char *argv[])
{
    if (argc != 3) {
        printf("Usage: %s MOUNTPOINT URI\n", argv[0]);
        return 1;
    }

    char *path = vfs_path_mkabsolute(cwd, argv[1]);
    errval_t err = vfs_mount(path, argv[2]);
    free(path);
    if (err_is_fail(err)) {
        DEBUG_ERR(err, "in vfs_mount %s %s", argv[1], argv[2]);
        return 1;
    }
    return 0;
}
예제 #19
0
파일: ps2kbd.c 프로젝트: Saruta/ToyOS
/*
 * Install the keyboard driver and initialize the
 * pipe device for userspace.
 */
static int keyboard_install(void) {
	debug_print(NOTICE, "Initializing PS/2 keyboard driver");

	/* Create a device pipe */
	keyboard_pipe = make_pipe(128);
	current_process->fds->entries[0] = keyboard_pipe;

	keyboard_pipe->flags = FS_CHARDEVICE;

	vfs_mount("/dev/kbd", keyboard_pipe);

	/* Install the interrupt handler */
	irq_install_handler(KEY_IRQ, keyboard_handler);

	return 0;
}
예제 #20
0
파일: devman.c 프로젝트: ALoay94/os
static void devman_init(void)
{
	debug("Loading device drivers ");
	dev_t **dev = devices;
	
	while(*dev)
	{
		(*dev)->probe(&dev_root);
		++dev;
		debug(".");
	}
	
	debug(" [done]\n");
	
	vfs_mount(vfs_root, "/dev", &dev_root);
}
예제 #21
0
static int _MsApi_BrickTerminator_Recover_NonReserve ()
{
    char cmd[CMD_BUF] = {};
    const char* BOOT_RECOVER_BRICK_BACKUP_VOLUME = "brickbackup";
    const char* BOOT_RECOVER_BRICK_BACKUP_FILE = "/MstarUpgrade_backup.bin";

    vfs_umount();
    if(0 == vfs_mount((char*)BOOT_RECOVER_BRICK_BACKUP_VOLUME))
    {
        sprintf(cmd, "bstar %s", BOOT_RECOVER_BRICK_BACKUP_FILE);
        UBOOT_ERROR("%s: ERROR: VFS failed, at %d\n", __func__, __LINE__);
        UBOOT_DEBUG("%s: DO BRICK RESERVE RECOVER, at %d\n", __func__, __LINE__);
        //NOTE: do partition recover
        run_command(cmd, 0);
        vfs_umount();
    }
    return 0;
}
예제 #22
0
static unsigned int LoadJpg2Dram(char *SrcPath,U32 Dram_Addr)
{
    char PathBuf[128] = "\0";
    U32 u32LogoSize=0;
    UBOOT_TRACE("IN\n");
    Dram_Addr=PA2NVA(Dram_Addr);
    UBOOT_DEBUG("PA2NVA(Dram_Addr)=0x%x\n",(unsigned int)Dram_Addr);

    vfs_mount(CUSTOMER);
    snprintf(PathBuf, sizeof(PathBuf), "%s/%s",CUSTOMER_PATH,SrcPath);
    UBOOT_DEBUG("PathBuf=%s\n",PathBuf);
    u32LogoSize = vfs_getsize(PathBuf);
    UBOOT_DEBUG("u32LogoSize=0x%x\n",(unsigned int)u32LogoSize);
    vfs_read((void *)Dram_Addr,PathBuf,0,u32LogoSize);

    UBOOT_TRACE("OK\n");
    return u32LogoSize;
}
예제 #23
0
int LoadMMAP(void)
{

    UBOOT_TRACE("IN\n");
  

    if(vfs_mount(CONFIG)!=0)
    {
        UBOOT_ERROR("mount %s fail\n",CONFIG);
        return -1;    
    }
    
    mmap_buffer_size=vfs_getsize(MMAP_FILE_NAME);
    if(mmap_buffer_size==0)
    {       
        UBOOT_ERROR("get the file size of %s fail\n",MMAP_FILE_NAME);
        return -1;
    }

    mmap_buffer=malloc(mmap_buffer_size);
    UBOOT_DEBUG("mmmap_buffer at 0x%x\n",(unsigned int)mmap_buffer);
    if(mmap_buffer==NULL)
    {
        UBOOT_ERROR("malloc for mmap_buffer fail\n");
        return NULL;
    }

    if(vfs_read((char *)mmap_buffer,MMAP_FILE_NAME,0,mmap_buffer_size)!=0)
    {
        free(mmap_buffer);
        mmap_buffer=NULL;
        UBOOT_ERROR("read %s fail\n",MMAP_FILE_NAME);
        return -1;
    }

    vfs_umount();
    

    UBOOT_TRACE("OK\n");    
    return 0;
}
예제 #24
0
uint32_t sys_mount(uint32_t param[4], uint32_t param_size[4])
{
	char *oldpath;
	char *newpath;
	char *fs;
	int status;
	if ((param_size[0] > CONFIG_FILE_MAX_NAME_LENGTH) || (param_size[1] > CONFIG_FILE_MAX_NAME_LENGTH)) {
		syscall_errno = EFAULT;
		return (uint32_t) -1;
	}
	oldpath = heapmm_alloc(param_size[0]);
	if (!copy_user_to_kern((void *)param[0], oldpath, param_size[0])) {
		syscall_errno = EFAULT;
		heapmm_free(oldpath, param_size[0]);
		return (uint32_t) -1;
	}
	newpath = heapmm_alloc(param_size[1]);
	if (!copy_user_to_kern((void *)param[1], newpath, param_size[1])) {
		syscall_errno = EFAULT;
		heapmm_free(oldpath, param_size[0]);
		heapmm_free(newpath, param_size[1]);
		return (uint32_t) -1;
	}
	fs = heapmm_alloc(param_size[2]);
	if (!copy_user_to_kern((void *)param[2], fs, param_size[2])) {
		syscall_errno = EFAULT;
		heapmm_free(oldpath, param_size[0]);
		heapmm_free(newpath, param_size[1]);
		heapmm_free(fs, param_size[2]);
		return (uint32_t) -1;
	}	
	status = vfs_mount(oldpath, newpath, fs, param[3]);
	if (status != 0) {
		syscall_errno = status;
		status = -1;
	}
	heapmm_free(oldpath, param_size[0]);
	heapmm_free(newpath, param_size[1]);
	heapmm_free(fs, param_size[2]);
	return (uint32_t) status;
}
예제 #25
0
파일: fs.c 프로젝트: Barracuda72/OS_64
void fs_init(void)
#endif
{
  char *rnn;

  kprintf("FS initialization...\n");
  vfs_node_t *main;

#ifdef __HOSTED__
  main = initrd_init(p, len);
  rnn = "initrd0";
#else
  main = ata_init();
  rnn = "ata0";
#endif

  dfs = devfs_init();

  devfs_add(main);

  root = vfs_alloc_node();
  root->name[0] = '/';
  root->name[1] = 0;

  root->flags = VFS_DIRECTORY;

  vfs_node_t *t = vfs_finddir(dfs, rnn);
  vfs_mount(t, root);

  if (root->ptr != NULL)
  {
    kprintf("Root mounted successfully\n");
  }

  tty_node = tty_init(NULL);
  devfs_add(tty_node);

  fs_print_dir(dfs);
}
예제 #26
0
파일: keyboard.c 프로젝트: thomasloven/os5
void keyboard_init()
{
  INODE tmp[2];
  new_pipe(1024, tmp);
  keyboard_pipe = tmp[1];
  /* vfs_mount("/dev/kbd", tmp[0]); */
  vfs_open(keyboard_pipe, O_WRONLY);

  // Make keyboard stdin (first entry in file descriptor table)
  process_t *p = current->proc;
  p->fd[0] = calloc(1, sizeof(file_desc_t));
  fd_get(p->fd[0]);
  p->fd[0]->ino = tmp[0];
  p->fd[0]->flags = O_RDONLY;
  vfs_open(tmp[0], O_RDONLY);

  new_pipe(1024, tmp);
  keyboard_raw = tmp[1];
  vfs_mount("/dev/kbdraw", tmp[0]);
  vfs_open(keyboard_raw, O_WRONLY);

  register_int_handler(IRQ2INT(IRQ_KBD), keyboard_handler);
}
예제 #27
0
파일: fstest.c 프로젝트: RobinVan/JMTK
void kmain(int argc, char **argv) {
  assert(argc > 2 && "Usage: fstest <fstype> <op> <params>");

  const char *fstype = argv[1];
  const char *op = argv[2];
  const char **params = (const char**) &argv[3];
  int nparams = argc - 2;

  /* Mount /dev/hda on / */
  int st = vfs_mount(makedev(DEV_MAJ_HDA, 0), vfs_get_root(), fstype);
  assert(st == 0 && "mount failed!");

  if (!strcmp(op, "cat"))
    op_cat(params, nparams);
  else if (!strcmp(op, "ls"))
    op_ls(params, nparams);
  else if (!strcmp(op, "write"))
    op_write(params, nparams);
  else if (!strcmp(op, "mkdir"))
    op_mkdir(params, nparams);
  else
    kprintf("Unknown command: %s!\n", op);
}
예제 #28
0
파일: vfs_bench.c 프로젝트: Karamax/arrakis
int main(int argc, char *argv[])
{
    errval_t err;

    // initialization
    vfs_init();
    bench_init();

    // mount nfs
    err = vfs_mkdir("/nfs");
    assert(err_is_ok(err));
    err = vfs_mount("/nfs", "nfs://10.110.4.4/local/nfs");
    assert(err_is_ok(err));

    // argument processing
    if (argc == 3) {
        printf("Started vfs_bench in command-line mode\n");

        int32_t chunksize = atol(argv[1]);
        int32_t repetitions = atol(argv[2]);

        single_run(chunksize, repetitions);
    } else {
        printf("Started vfs_bench.\n");

        for (int32_t i = 1; i < 20; i++) {
            single_run(4096, i * 2000);
        }
    }

    //err = vfs_unmount("/nfs"); // unmount is NYI
    //assert(err_is_ok(err));
    err = vfs_rmdir("/nfs");
    assert(err_is_ok(err));

    return 0;
}
예제 #29
0
static int check_not_empty(void)
{   
    UBOOT_TRACE("IN\n"); 
    int ret=0;    
    if(fpIsStorageEmpty==NULL)
    {
        #if (ENABLE_MODULE_MMC==1)
        UBOOT_DEBUG("storage is mmc\n");
        ret=run_command("mmc look certificate",0);
        #elif (ENABLE_MODULE_UBI_FS==1)
        UBOOT_DEBUG("storage is nand, and use ubifs\n");        
        ret=vfs_mount(CUSTOMER);
        #else            
        UBOOT_DEBUG("unknown storage\n");                
        ret=-1;
        #endif            
        if(ret==-1)
        {
            UBOOT_INFO("storage is empty\n");
            UBOOT_TRACE("OK\n");
            return -1;
        }
    }
    else
    {
        UBOOT_DEBUG("Detect by custmoer's call back function\n");
        if(fpIsStorageEmpty()!=0)
        {
            UBOOT_INFO("storage is empty\n");
            UBOOT_TRACE("OK\n");
            return -1;
        }
    }
    UBOOT_TRACE("OK\n");
    return 0; //flash is not empty
}
예제 #30
0
파일: demo.c 프로젝트: pagxir/deadshot
int main(int argc, char *argv[])
{
    int count;
    char buf[1024];
    struct vfs_node file;

    if (argc < 2) {
        printf("too few argument!\n");
        return -1;
    }

    if (vfs_mount(argv[1], &fat_fs)) {
        printf("vfs_mount fail\n");
        return -1;
    }

    if (vfs_open(argv[2], &file)) {
        printf("vfs_open fail\n");
        return -1;
    }

    FILE * fout = fopen(argc < 4? "fout.txt": argv[3], "wb");
    if (fout != NULL) {
        while (!vfs_read(&file, buf, sizeof(buf), &count) && count > 0)
            fwrite(buf, 1, count, fout);
        fclose(fout);
    }

    if (vfs_close(&file)) {
        printf("vfs_close fail\n");
        return -1;
    }

    printf("test success\n");
    return 0;
}