summaryrefslogtreecommitdiffstats
path: root/qemu/roms/u-boot/fs/fat/file.c
diff options
context:
space:
mode:
authorRajithaY <rajithax.yerrumsetty@intel.com>2017-04-25 03:31:15 -0700
committerRajitha Yerrumchetty <rajithax.yerrumsetty@intel.com>2017-05-22 06:48:08 +0000
commitbb756eebdac6fd24e8919e2c43f7d2c8c4091f59 (patch)
treeca11e03542edf2d8f631efeca5e1626d211107e3 /qemu/roms/u-boot/fs/fat/file.c
parenta14b48d18a9ed03ec191cf16b162206998a895ce (diff)
Adding qemu as a submodule of KVMFORNFV
This Patch includes the changes to add qemu as a submodule to kvmfornfv repo and make use of the updated latest qemu for the execution of all testcase Change-Id: I1280af507a857675c7f81d30c95255635667bdd7 Signed-off-by:RajithaY<rajithax.yerrumsetty@intel.com>
Diffstat (limited to 'qemu/roms/u-boot/fs/fat/file.c')
-rw-r--r--qemu/roms/u-boot/fs/fat/file.c184
1 files changed, 0 insertions, 184 deletions
diff --git a/qemu/roms/u-boot/fs/fat/file.c b/qemu/roms/u-boot/fs/fat/file.c
deleted file mode 100644
index d910c46dd..000000000
--- a/qemu/roms/u-boot/fs/fat/file.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * file.c
- *
- * Mini "VFS" by Marcus Sundberg
- *
- * 2002-07-28 - rjones@nexus-tech.net - ported to ppcboot v1.1.6
- * 2003-03-10 - kharris@nexus-tech.net - ported to uboot
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#include <common.h>
-#include <config.h>
-#include <malloc.h>
-#include <fat.h>
-#include <linux/stat.h>
-#include <linux/time.h>
-
-/* Supported filesystems */
-static const struct filesystem filesystems[] = {
- { file_fat_detectfs, file_fat_ls, file_fat_read, "FAT" },
-};
-#define NUM_FILESYS (sizeof(filesystems)/sizeof(struct filesystem))
-
-/* The filesystem which was last detected */
-static int current_filesystem = FSTYPE_NONE;
-
-/* The current working directory */
-#define CWD_LEN 511
-char file_cwd[CWD_LEN+1] = "/";
-
-const char *
-file_getfsname(int idx)
-{
- if (idx < 0 || idx >= NUM_FILESYS)
- return NULL;
-
- return filesystems[idx].name;
-}
-
-static void
-pathcpy(char *dest, const char *src)
-{
- char *origdest = dest;
-
- do {
- if (dest-file_cwd >= CWD_LEN) {
- *dest = '\0';
- return;
- }
- *(dest) = *(src);
- if (*src == '\0') {
- if (dest-- != origdest && ISDIRDELIM(*dest)) {
- *dest = '\0';
- }
- return;
- }
- ++dest;
-
- if (ISDIRDELIM(*src))
- while (ISDIRDELIM(*src)) src++;
- else
- src++;
- } while (1);
-}
-
-int
-file_cd(const char *path)
-{
- if (ISDIRDELIM(*path)) {
- while (ISDIRDELIM(*path)) path++;
- strncpy(file_cwd+1, path, CWD_LEN-1);
- } else {
- const char *origpath = path;
- char *tmpstr = file_cwd;
- int back = 0;
-
- while (*tmpstr != '\0') tmpstr++;
- do {
- tmpstr--;
- } while (ISDIRDELIM(*tmpstr));
-
- while (*path == '.') {
- path++;
- while (*path == '.') {
- path++;
- back++;
- }
- if (*path != '\0' && !ISDIRDELIM(*path)) {
- path = origpath;
- back = 0;
- break;
- }
- while (ISDIRDELIM(*path)) path++;
- origpath = path;
- }
-
- while (back--) {
- /* Strip off path component */
- while (!ISDIRDELIM(*tmpstr)) {
- tmpstr--;
- }
- if (tmpstr == file_cwd) {
- /* Incremented again right after the loop. */
- tmpstr--;
- break;
- }
- /* Skip delimiters */
- while (ISDIRDELIM(*tmpstr)) tmpstr--;
- }
- tmpstr++;
- if (*path == '\0') {
- if (tmpstr == file_cwd) {
- *tmpstr = '/';
- tmpstr++;
- }
- *tmpstr = '\0';
- return 0;
- }
- *tmpstr = '/';
- pathcpy(tmpstr+1, path);
- }
-
- return 0;
-}
-
-int
-file_detectfs(void)
-{
- int i;
-
- current_filesystem = FSTYPE_NONE;
-
- for (i = 0; i < NUM_FILESYS; i++) {
- if (filesystems[i].detect() == 0) {
- strcpy(file_cwd, "/");
- current_filesystem = i;
- break;
- }
- }
-
- return current_filesystem;
-}
-
-int
-file_ls(const char *dir)
-{
- char fullpath[1024];
- const char *arg;
-
- if (current_filesystem == FSTYPE_NONE) {
- printf("Can't list files without a filesystem!\n");
- return -1;
- }
-
- if (ISDIRDELIM(*dir)) {
- arg = dir;
- } else {
- sprintf(fullpath, "%s/%s", file_cwd, dir);
- arg = fullpath;
- }
- return filesystems[current_filesystem].ls(arg);
-}
-
-long
-file_read(const char *filename, void *buffer, unsigned long maxsize)
-{
- char fullpath[1024];
- const char *arg;
-
- if (current_filesystem == FSTYPE_NONE) {
- printf("Can't load file without a filesystem!\n");
- return -1;
- }
-
- if (ISDIRDELIM(*filename)) {
- arg = filename;
- } else {
- sprintf(fullpath, "%s/%s", file_cwd, filename);
- arg = fullpath;
- }
-
- return filesystems[current_filesystem].read(arg, buffer, maxsize);
-}