📄 fat.c
字号:
/* * fat.c * * R/O (V)FAT 12/16/32 filesystem implementation 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 * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */#include <common.h>#include <config.h>#include <fat.h>#include <asm/byteorder.h>#if (CONFIG_COMMANDS & CFG_CMD_FAT)/* * Convert a string to lowercase. */static voiddowncase(char *str){ while (*str != '\0') { TOLOWER(*str); str++; }}int (*dev_block_read)(int device, __u32 blknr, __u32 blkcnt, __u8 *buffer) = 0;int disk_read (__u32 startblock, __u32 getsize, __u8 * bufptr){ /* FIXME we need to determine the start block of the * partition where the DOS FS resides */ startblock += 32; if (dev_block_read) { return dev_block_read (0, startblock, getsize, bufptr); } return -1;}intfat_register_read (int (*block_read)(int, __u32, __u32, __u8 *)){ dev_block_read = block_read; return 0;}/* * Get the first occurence of a directory delimiter ('/' or '\') in a string. * Return index into string if found, -1 otherwise. */static intdirdelim(char *str){ char *start = str; while (*str != '\0') { if (ISDIRDELIM(*str)) return str - start; str++; } return -1;}/* * Match volume_info fs_type strings. * Return 0 on match, -1 otherwise. */static intcompare_sign(char *str1, char *str2){ char *end = str1+SIGNLEN; while (str1 != end) { if (*str1 != *str2) { return -1; } str1++; str2++; } return 0;}/* * Extract zero terminated short name from a directory entry. */static void get_name (dir_entry *dirent, char *s_name){ char *ptr; memcpy (s_name, dirent->name, 8); s_name[8] = '\0'; ptr = s_name; while (*ptr && *ptr != ' ') ptr++; if (dirent->ext[0] && dirent->ext[0] != ' ') { *ptr = '.'; ptr++; memcpy (ptr, dirent->ext, 3); ptr[3] = '\0'; while (*ptr && *ptr != ' ') ptr++; } *ptr = '\0'; if (*s_name == DELETED_FLAG) *s_name = '\0'; else if (*s_name == aRING) *s_name = '
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -