file_system/fat: Rework driver for fs_shell support

* Introduce fat_shell for build system fat manipulation
* Will theoretically let us do away with mtools when we
  have another internal tool for partition manipulation

Change-Id: I661be556e79009842f157a9402c8f85da85d6336
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3556
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Alexander von Gluck IV 2020-12-29 12:42:21 -06:00
parent aa013a511f
commit 9f3ba01bd3
24 changed files with 259 additions and 181 deletions

View File

@ -1402,6 +1402,8 @@
#define index fssh_index
#define rindex fssh_rindex
/* SMAP-specific functions */
#define user_strlcpy fssh_strlcpy
////////////////////////////////////////////////////////////////////////////////
// #pragma mark - fssh_time.h

View File

@ -2,22 +2,20 @@ SubDir HAIKU_TOP src add-ons kernel file_systems fat ;
UsePrivateKernelHeaders ;
SubDirCcFlags -DTRACK_FILENAME ;
KernelAddon fat :
attr.c
dir.c
dlist.c
dosfs.c
attr.cpp
dir.cpp
dlist.cpp
dosfs.cpp
encodings.cpp
fat.c
file.c
iter.c
fat.cpp
file.cpp
iter.cpp
mime_ext_table.c
mkdos.cpp
util.c
vcache.c
version.c
util.cpp
vcache.cpp
version.cpp
;
SEARCH on [ FGristFiles mime_ext_table.c ]

View File

@ -11,25 +11,27 @@
#define MIME_STRING_TYPE 'MIMS'
#include <SupportDefs.h>
#include <KernelExport.h>
#include "system_dependencies.h"
#include <dirent.h>
#ifndef FS_SHELL
#include <file_systems/mime_ext_table.h>
#include <fs_attr.h>
#include <string.h>
#include <malloc.h>
#endif
#include "dosfs.h"
#include "attr.h"
int32 kBeOSTypeCookie = 0x1234;
#define DPRINTF(a,b) if (debug_attr > (a)) dprintf b
status_t set_mime_type(vnode *node, const char *filename)
{
#ifdef FS_SHELL
return B_ERROR;
#else
return set_mime(&node->mime, filename);
#endif
}
@ -234,7 +236,7 @@ dosfs_read_attr(fs_volume *_vol, fs_vnode *_node, void *_cookie, off_t pos,
return EINVAL;
}
length = user_strlcpy(buffer, node->mime + pos, *_length);
length = user_strlcpy((char*)buffer, node->mime + pos, *_length);
if (length < B_OK) {
UNLOCK_VOL(vol);
return B_BAD_ADDRESS;

View File

@ -5,7 +5,7 @@
#ifndef _DOSFS_ATTR_H_
#define _DOSFS_ATTR_H_
#include <fs_attr.h>
#include "system_dependencies.h"
status_t set_mime_type(vnode *node, const char *filename);

View File

@ -5,15 +5,7 @@
#include "dir.h"
#include <dirent.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <fs_cache.h>
#include <fs_info.h>
#include <KernelExport.h>
#include "system_dependencies.h"
#include "iter.h"
#include "dosfs.h"
@ -28,9 +20,6 @@
#define DPRINTF(a,b) if (debug_dir > (a)) dprintf b
// used here and in encodings.cpp
const char acceptable[]="!#$%&'()-0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`{}~";
const char illegal[] = "\\/:*?\"<>|";
typedef struct dircookie {
uint32 current_index;
@ -826,7 +815,7 @@ is_filename_legal(const char *name)
for (i = 0; i < len; i++) {
if (name[i] & 0x80)
continue; //belongs to an utf8 char
if (strchr(illegal, name[i]))
if (strchr(sIllegal, name[i]))
return false;
if ((unsigned char)name[i] < 32)
return false;
@ -937,7 +926,7 @@ status_t
dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
uint32 *_flags, bool reenter)
{
nspace *vol = (nspace*)_vol->private_volume;
nspace *vol = (nspace *)_vol->private_volume;
int result = B_NO_ERROR;
ino_t loc, dir_vnid;
vnode *entry;
@ -1007,7 +996,7 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
}
}
if ((entry = calloc(sizeof(struct vnode), 1)) == NULL) {
if ((entry = (vnode *)calloc(sizeof(struct vnode), 1)) == NULL) {
DPRINTF(0, ("dosfs_read_vnode: out of memory\n"));
result = ENOMEM;
goto bi2;
@ -1044,10 +1033,10 @@ dosfs_read_vnode(fs_volume *_vol, ino_t vnid, fs_vnode *_node, int *_type,
entry->end_cluster = 0;
entry->st_time = dos2time_t(info.time);
entry->st_crtim = dos2time_t(info.creation_time);
#if TRACK_FILENAME
entry->filename = malloc(sizeof(filename) + 1);
entry->filename = (char *)malloc(sizeof(filename) + 1);
if (entry->filename) strcpy(entry->filename, filename);
#endif
entry->cache = file_cache_create(vol->id, vnid, entry->st_size);
entry->file_map = file_map_create(vol->id, vnid, entry->st_size);
if (!(entry->mode & FAT_SUBDIR))
@ -1073,8 +1062,8 @@ dosfs_walk(fs_volume *_vol, fs_vnode *_dir, const char *file, ino_t *_vnid)
{
/* Starting at the base, find file in the subdir, and return path
string and vnode id of file. */
nspace *vol = (nspace*)_vol->private_volume;
vnode *dir = (vnode*)_dir->private_node;
nspace *vol = (nspace *)_vol->private_volume;
vnode *dir = (vnode *)_dir->private_node;
vnode *vnode = NULL;
status_t result = ENOENT;
@ -1141,8 +1130,8 @@ dosfs_readlink(fs_volume *_vol, fs_vnode *_node, char *buf, size_t *bufsize)
status_t
dosfs_opendir(fs_volume *_vol, fs_vnode *_node, void **_cookie)
{
nspace *vol = (nspace*)_vol->private_volume;
vnode *node = (vnode*)_node->private_node;
nspace *vol = (nspace *)_vol->private_volume;
vnode *node = (vnode *)_node->private_node;
dircookie *cookie = NULL;
int result;
@ -1173,7 +1162,7 @@ dosfs_opendir(fs_volume *_vol, fs_vnode *_node, void **_cookie)
result = B_NO_ERROR;
bi:
*_cookie = (void*)cookie;
*_cookie = (void *)cookie;
if (result != B_OK)
DPRINTF(0, ("dosfs_opendir (%s)\n", strerror(result)));
@ -1189,9 +1178,9 @@ dosfs_readdir(fs_volume *_vol, fs_vnode *_dir, void *_cookie,
struct dirent *entry, size_t bufsize, uint32 *num)
{
int result = ENOENT;
nspace* vol = (nspace*)_vol->private_volume;
nspace* vol = (nspace *)_vol->private_volume;
vnode *dir = (vnode *)_dir->private_node;
dircookie* cookie = (dircookie*)_cookie;
dircookie* cookie = (dircookie *)_cookie;
struct diri diri;
LOCK_VOL(vol);
@ -1265,7 +1254,7 @@ dosfs_rewinddir(fs_volume *_vol, fs_vnode *_node, void* _cookie)
{
nspace *vol = (nspace *)_vol->private_volume;
vnode *node = (vnode *)_node->private_node;
dircookie *cookie = (dircookie*)_cookie;
dircookie *cookie = (dircookie *)_cookie;
LOCK_VOL(vol);
@ -1295,7 +1284,7 @@ dosfs_free_dircookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
{
nspace *vol = (nspace *)_vol->private_volume;
vnode *node = (vnode *)_node->private_node;
dircookie *cookie = _cookie;
dircookie *cookie = (dircookie *)_cookie;
LOCK_VOL(vol);

View File

@ -19,10 +19,7 @@ TODO:
#define DPRINTF(a,b) if (debug_dlist > (a)) dprintf b
#include <KernelExport.h>
#include <stdlib.h>
#include <string.h>
#include "system_dependencies.h"
#include "dosfs.h"
#include "dlist.h"
@ -43,7 +40,7 @@ dlist_init(nspace *vol)
vol->dlist.entries = 0;
vol->dlist.allocated = DLIST_ENTRY_QUANTUM;
vol->dlist.vnid_list = malloc(sizeof(ino_t) * vol->dlist.allocated);
vol->dlist.vnid_list = (ino_t *)malloc(sizeof(ino_t) * vol->dlist.allocated);
if (vol->dlist.vnid_list == NULL) {
vol->dlist.allocated = 0;
dprintf("dlist_init: out of core\n");
@ -79,7 +76,7 @@ dlist_realloc(nspace *vol, uint32 allocate)
ASSERT(allocate != vol->dlist.allocated);
ASSERT(allocate > vol->dlist.entries);
vnid_list = malloc(sizeof(ino_t) * allocate);
vnid_list = (ino_t *)malloc(sizeof(ino_t) * allocate);
if (vnid_list == NULL) {
dprintf("dlist_realloc: out of core\n");
return ENOMEM;

View File

@ -6,22 +6,7 @@
#include "dosfs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <KernelExport.h>
#include <Drivers.h>
#include <driver_settings.h>
#include <scsi.h>
#include <fs_info.h>
#include <fs_interface.h>
#include <fs_cache.h>
#include <fs_volume.h>
#include "system_dependencies.h"
#include "attr.h"
#include "dir.h"
@ -109,9 +94,8 @@ debug_dvnode(int argc, char **argv)
if (!n) continue;
kprintf("vnode @ %p", n);
#if TRACK_FILENAME
kprintf(" (%s)", n->filename);
#endif
kprintf("\nvnid %" B_PRIdINO ", dir vnid %" B_PRIdINO "\n", n->vnid,
n->dir_vnid);
kprintf("iteration %" B_PRIu32 ", si=%" B_PRIu32 ", ei=%" B_PRIu32
@ -498,13 +482,6 @@ volume_count_free_cluster(nspace *vol)
}
static int
lock_removable_device(int fd, bool state)
{
return ioctl(fd, B_SCSI_PREVENT_ALLOW, &state, sizeof(state));
}
static status_t
mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
nspace** newVol, int fs_flags, int op_sync_mode)
@ -564,10 +541,6 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
strerror(err));
goto error0;
}
if ((vol_flags & B_FS_IS_REMOVABLE)
&& (fs_flags & FS_FLAGS_LOCK_DOOR))
lock_removable_device(fd, true);
}
// see if we need to go into op sync mode
@ -685,11 +658,6 @@ mount_fat_disk(const char *path, fs_volume *_vol, const int flags,
error3:
uninit_vcache(vol);
error2:
if (!(vol->flags & B_FS_IS_READONLY) && (vol->flags & B_FS_IS_REMOVABLE)
&& (vol->fs_flags & FS_FLAGS_LOCK_DOOR)) {
lock_removable_device(fd, false);
}
volume_uninit(vol);
error1:
close(fd);
@ -941,14 +909,14 @@ update_fsinfo(nspace *vol)
static status_t
get_fsinfo(nspace *vol, uint32 *free_count, uint32 *last_allocated)
{
uchar *buffer;
char *buffer;
status_t result;
if ((vol->fat_bits != 32) || (vol->fsinfo_sector == 0xffff))
return B_ERROR;
result = block_cache_get_etc(vol->fBlockCache, vol->fsinfo_sector, 0,
vol->bytes_per_sector, &buffer);
vol->bytes_per_sector, (const void**)&buffer);
if (result != B_OK) {
dprintf("get_fsinfo: error getting fsinfo sector %x: %s\n",
vol->fsinfo_sector, strerror(result));
@ -999,8 +967,6 @@ dosfs_unmount(fs_volume *_vol)
dlist_uninit(vol);
uninit_vcache(vol);
if (!(vol->flags & B_FS_IS_READONLY) && (vol->flags & B_FS_IS_REMOVABLE) && (vol->fs_flags & FS_FLAGS_LOCK_DOOR))
lock_removable_device(vol->fd, false);
result = close(vol->fd);
recursive_lock_destroy(&(vol->vlock));
free(vol);
@ -1083,11 +1049,10 @@ dosfs_write_fs_stat(fs_volume *_vol, const struct fs_info * fss, uint32 mask)
memset(name, ' ', 11);
DPRINTF(1, ("wfsstat: setting name to %s\n", fss->volume_name));
for (i=j=0;(i<11)&&(fss->volume_name[j]);j++) {
static char acceptable[] = "!#$%&'()-0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`{}~";
char c = fss->volume_name[j];
if ((c >= 'a') && (c <= 'z')) c += 'A' - 'a';
// spaces acceptable in volume names
if (strchr(acceptable, c) || (c == ' '))
if (strchr(sAcceptable, c) || (c == ' '))
name[i++] = c;
}
if (i == 0) { // bad name, kiddo

View File

@ -6,9 +6,7 @@
#define _DOSFS_H_
#include <KernelExport.h>
#include <fs_interface.h>
#include <lock.h>
#include "system_dependencies.h"
//#define DEBUG 1
@ -94,9 +92,7 @@ typedef struct vnode {
bool dirty; // track if vnode had been written to
#if TRACK_FILENAME
char *filename;
#endif
} vnode;
// mode bits

View File

@ -11,10 +11,8 @@
#include <string.h>
#include "encodings.h"
extern "C" {
#include "util.h"
extern int debug_encodings;
}
#define TOUCH(x) ((void)(x))
@ -1148,10 +1146,6 @@ status_t unicode_to_utf8(const uchar *uni, uint32 unilen, uint8 *utf8,
}
// from dir.c
extern "C" {
extern const char acceptable[];
extern const char illegal[];
}
const char underbar[] = "+,;=[]"
"\x83\x85\x88\x89\x8A\x8B\x8C\x8D"
"\x93\x95\x96\x97\x98"
@ -1180,7 +1174,7 @@ bool requires_long_name(const char *utf8, const uchar *unicode)
if (utf8[i] == '.') break;
/* XXX: should also check for upper-ascii stuff (requires matching
* unicode with msdostou table, but doesn't hurt for now */
if (!strchr(acceptable, utf8[i])) return true;
if (!strchr(sAcceptable, utf8[i])) return true;
}
if (utf8[i] == 0) return false;
@ -1191,7 +1185,7 @@ bool requires_long_name(const char *utf8, const uchar *unicode)
for (j=0;j<3;j++,i++) {
if (utf8[i] == 0) return false;
/* XXX: same here */
if (!strchr(acceptable, utf8[i])) return true;
if (!strchr(sAcceptable, utf8[i])) return true;
}
return (utf8[i] == 0) ? false : true;
@ -1339,7 +1333,7 @@ generate_short_name_msdos(const uchar *utf8, const uint16 *uni,
break;
if (c < 0x100) {
if (strchr(illegal, c)) return EINVAL;
if (strchr(sIllegal, c)) return EINVAL;
if ((c >= 'a') && (c <= 'z'))
nshort[i++] = c - 'a' + 'A';
@ -1347,7 +1341,7 @@ generate_short_name_msdos(const uchar *utf8, const uint16 *uni,
nshort[i++] = '_';
else if ((cp = strchr(capitalize_from, c)) != NULL)
nshort[i++] = capitalize_to[(int)(cp - capitalize_from)];
else if (strchr(acceptable, c) || strchr(capitalize_to, c))
else if (strchr(sAcceptable, c) || strchr(capitalize_to, c))
nshort[i++] = c;
}
}
@ -1373,7 +1367,7 @@ generate_short_name_msdos(const uchar *utf8, const uint16 *uni,
break;
if (c < 0x100) {
if (strchr(illegal, c)) return EINVAL;
if (strchr(sIllegal, c)) return EINVAL;
if ((c >= 'a') && (c <= 'z'))
nshort[i++] = c - 'a' + 'A';
@ -1381,7 +1375,7 @@ generate_short_name_msdos(const uchar *utf8, const uint16 *uni,
nshort[i++] = '_';
else if ((cp = strchr(capitalize_from, c)) != NULL)
nshort[i++] = capitalize_to[(int)(cp - capitalize_from)];
else if (strchr(acceptable, c) || strchr(capitalize_to, c))
else if (strchr(sAcceptable, c) || strchr(capitalize_to, c))
nshort[i++] = c;
}
}

View File

@ -5,6 +5,10 @@
#ifndef _DOSFS_ENCODINGS_H_
#define _DOSFS_ENCODINGS_H_
#include "system_dependencies.h"
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -6,12 +6,7 @@
#include "fat.h"
#include <stdlib.h>
#include <string.h>
#include <fs_cache.h>
#include <ByteOrder.h>
#include <KernelExport.h>
#include "system_dependencies.h"
#include "dosfs.h"
#include "file.h"
@ -42,7 +37,8 @@ mirror_fats(nspace *vol, uint32 sector, uint8 *buffer)
continue;
status = block_cache_get_writable_etc(vol->fBlockCache,
sector + i * vol->sectors_per_fat, 0, 1, -1, &blockData);
sector + i * vol->sectors_per_fat, 0, 1, -1,
(void**)&blockData);
if (status != B_OK)
return status;

View File

@ -3,17 +3,7 @@
This file may be used under the terms of the Be Sample Code License.
*/
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <fs_cache.h>
#include <fs_info.h>
#include <Drivers.h>
#include <KernelExport.h>
#include <NodeMonitor.h>
#include <time.h>
#include "system_dependencies.h"
#include "iter.h"
#include "dosfs.h"
@ -144,9 +134,7 @@ dosfs_release_vnode(fs_volume *_vol, fs_vnode *_node, bool reenter)
UNLOCK_VOL(vol);
}
#if TRACK_FILENAME
if (node->filename) free(node->filename);
#endif
if (node->vnid != vol->root_vnode.vnid) {
file_cache_delete(node->cache);
@ -331,7 +319,7 @@ dosfs_open(fs_volume *_vol, fs_vnode *_node, int omode, void **_cookie)
node->iteration++;
}
if ((cookie = calloc(sizeof(filecookie), 1)) == NULL) {
if ((cookie = (filecookie*)calloc(sizeof(filecookie), 1)) == NULL) {
result = ENOMEM;
goto error;
}
@ -497,9 +485,9 @@ dosfs_close(fs_volume *_vol, fs_vnode *_node, void *_cookie)
status_t
dosfs_free_cookie(fs_volume *_vol, fs_vnode *_node, void *_cookie)
{
nspace *vol = _vol->private_volume;
vnode *node = _node->private_node;
filecookie *cookie = _cookie;
nspace *vol = (nspace *)_vol->private_volume;
vnode *node = (vnode *)_node->private_node;
filecookie *cookie = (filecookie *)_cookie;
LOCK_VOL(vol);
DPRINTF(0, ("dosfs_free_cookie (vnode id %" B_PRIdINO ")\n", node->vnid));
@ -554,7 +542,7 @@ dosfs_create(fs_volume *_vol, fs_vnode *_dir, const char *name, int omode,
}
// create file cookie; do it here to make cleaning up easier
if ((cookie = calloc(sizeof(filecookie), 1)) == NULL) {
if ((cookie = (filecookie *)calloc(sizeof(filecookie), 1)) == NULL) {
result = ENOMEM;
goto bi;
}
@ -717,7 +705,7 @@ dosfs_mkdir(fs_volume *_vol, fs_vnode *_dir, const char *name, int perms)
goto bi3;
}
buffer = malloc(vol->bytes_per_sector);
buffer = (uchar *)malloc(vol->bytes_per_sector);
if (!buffer) {
result = ENOMEM;
goto bi4;
@ -1006,11 +994,9 @@ dosfs_rename(fs_volume *_vol, fs_vnode *_odir, const char *oldname,
diri_free(&diri);
}
#if TRACK_FILENAME
if (file->filename) free(file->filename);
file->filename = malloc(strlen(newname) + 1);
file->filename = (char*)malloc(strlen(newname) + 1);
if (file->filename) strcpy(file->filename, newname);
#endif
notify_entry_moved(vol->id, odir->vnid, oldname, ndir->vnid, newname,
file->vnid);
@ -1374,7 +1360,7 @@ dosfs_get_file_map(fs_volume *_vol, fs_vnode *_node, off_t position,
off_t block = csi_to_block(&iter);
uint32 sectors = 1;
length -= min(length, vol->bytes_per_sector - offset);
length -= min_c(length, vol->bytes_per_sector - offset);
while (length > 0) {
result = iter_csi(&iter, 1);
@ -1389,7 +1375,7 @@ dosfs_get_file_map(fs_volume *_vol, fs_vnode *_node, off_t position,
break;
}
length -= min(length, vol->bytes_per_sector);
length -= min_c(length, vol->bytes_per_sector);
sectors++;
}

View File

@ -6,11 +6,7 @@
#include "iter.h"
#include <string.h>
#include <fs_cache.h>
#include <fs_info.h>
#include <KernelExport.h>
#include "system_dependencies.h"
#include "dosfs.h"
#include "fat.h"
@ -222,7 +218,7 @@ csi_write_blocks(struct csi *csi, uint8 *buffer, ssize_t len)
for (i = block; i < block + sectors; i++) {
char *blockData;
status_t status = block_cache_get_writable_etc(csi->vol->fBlockCache,
i, 0, 1, -1, &blockData);
i, 0, 1, -1, (void**)&blockData);
if (status != B_OK)
return status;
@ -254,7 +250,7 @@ csi_write_block(struct csi *csi, uint8 *buffer)
return EINVAL;
status = block_cache_get_writable_etc(csi->vol->fBlockCache, block, 0, 1,
-1, &blockData);
-1, (void**)&blockData);
if (status != B_OK)
return status;

View File

@ -6,7 +6,11 @@
#define _DOSFS_ITER_H_
#include <SupportDefs.h>
#ifdef FS_SHELL
# include "system_dependencies.h"
#else
# include <SupportDefs.h>
#endif
struct _nspace;

View File

@ -6,18 +6,7 @@
*/
#include <ByteOrder.h>
#include <Drivers.h>
#include <driver_settings.h>
#include <KernelExport.h>
#include <OS.h>
#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include "system_dependencies.h"
#define MKDOS
#include "mkdos.h"
@ -71,7 +60,7 @@ parse_initialize_parameters(const char* parameterString,
delete_driver_settings(handle);
if (fatBits != 0 && fatBits != 12 && fatBits != 16 && fatBits != 32) {
printf("mkdos error: fat must be 12, 16, or 32 bits\n");
dprintf("mkdos error: fat must be 12, 16, or 32 bits\n");
return B_BAD_VALUE;
}
@ -747,7 +736,7 @@ void CreateVolumeLabel(void *sector, const char *label)
// XXX this could be changed to use long file name entrys,
// XXX but the dosfs would have to be updated, too
dirent *d = (dirent *)sector;
fatdirent *d = (fatdirent *)sector;
memset(d, 0, sizeof(*d));
memset(d->Name, 0x20, 11);
memcpy(d->Name, label, min_c(11, strlen(label)));

View File

@ -26,7 +26,7 @@ THE SOFTWARE.
*/
#include <fs_interface.h>
#include "system_dependencies.h"
struct initialize_parameters {
@ -124,7 +124,7 @@ struct fsinfosector32 {
// a FAT directory entry
struct dirent {
struct fatdirent {
uint8 Name[11];
uint8 Attr;
uint8 NTRes;

View File

@ -0,0 +1,62 @@
/*
* Copyright 2007, Ingo Weinhold, bonefish@cs.tu-berlin.de.
* Distributed under the terms of the MIT License.
*/
#ifndef _SYSTEM_DEPENDENCIES_H
#define _SYSTEM_DEPENDENCIES_H
#ifdef FS_SHELL
typedef unsigned char uchar;
#include "fssh_api_wrapper.h"
#include "fssh_auto_deleter.h"
#else // !FS_SHELL
#include <AutoDeleter.h>
#include <util/AutoLock.h>
#include <util/DoublyLinkedList.h>
#include <util/SinglyLinkedList.h>
#include <util/Stack.h>
#include <ByteOrder.h>
#ifndef _BOOT_MODE
# include <tracing.h>
# include <driver_settings.h>
# include <fs_attr.h>
# include <fs_cache.h>
# include <fs_index.h>
# include <fs_info.h>
# include <fs_interface.h>
# include <fs_query.h>
# include <fs_volume.h>
# include <Drivers.h>
# include <KernelExport.h>
# include <NodeMonitor.h>
# include <SupportDefs.h>
# include <TypeConstants.h>
#endif // _BOOT_MODE
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <getopt.h>
#include <malloc.h>
#include <new>
#include <null.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#endif // !FS_SHELL
#endif // _SYSTEM_DEPENDENCIES_H

View File

@ -4,14 +4,11 @@
*/
#include <SupportDefs.h>
#include <KernelExport.h>
#include "system_dependencies.h"
#ifndef FS_SHELL
#include <real_time_clock.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#endif
#include "dosfs.h"
#include "fat.h"
@ -73,7 +70,12 @@ get_tzoffset()
if (tzoffset != -1)
return;
#ifdef FS_SHELL
// We just assume UTC ;-)
tzoffset = 0;
#else
tzoffset = get_timezone_offset() / 60;
#endif
}

View File

@ -6,7 +6,11 @@
#define _DOSFS_UTIL_H_
#include <ByteOrder.h>
#include "system_dependencies.h"
const char sAcceptable[]="!#$%&'()-0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`{}~";
const char sIllegal[] = "\\/:*?\"<>|";
// debugging functions

View File

@ -39,11 +39,7 @@ purpose.
#include "vcache.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <KernelExport.h>
#include "system_dependencies.h"
#include "dosfs.h"
#include "util.h"
@ -101,14 +97,14 @@ init_vcache(nspace *vol)
vol->vcache.cache_size = 512; /* must be power of 2 */
#endif
vol->vcache.by_vnid = calloc(sizeof(struct vache_entry *),
vol->vcache.by_vnid = (vcache_entry**)calloc(sizeof(struct vache_entry *),
vol->vcache.cache_size);
if (vol->vcache.by_vnid == NULL) {
dprintf("init_vcache: out of memory\n");
return ENOMEM;
}
vol->vcache.by_loc = calloc(sizeof(struct vache_entry *),
vol->vcache.by_loc = (vcache_entry**)calloc(sizeof(struct vache_entry *),
vol->vcache.cache_size);
if (vol->vcache.by_loc == NULL) {
dprintf("init_vcache: out of memory\n");
@ -177,7 +173,7 @@ _add_to_vcache_(nspace *vol, ino_t vnid, ino_t loc)
ASSERT(vnid != loc);
e = malloc(sizeof(struct vcache_entry));
e = (vcache_entry*)malloc(sizeof(struct vcache_entry));
if (e == NULL)
return ENOMEM;

View File

@ -91,6 +91,7 @@ SEARCH on [ FGristFiles
SubInclude HAIKU_TOP src tools addattr ;
SubInclude HAIKU_TOP src tools anyboot ;
SubInclude HAIKU_TOP src tools bfs_shell ;
SubInclude HAIKU_TOP src tools fat_shell ;
SubInclude HAIKU_TOP src tools cppunit ;
SubInclude HAIKU_TOP src tools create_repository_config ;
SubInclude HAIKU_TOP src tools elfsymbolpatcher ;

View File

@ -0,0 +1,85 @@
SubDir HAIKU_TOP src tools fat_shell ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems fat ] ;
# prevent inclusion of HaikuBuildCompatibility.h and BSD headers
DEFINES += HAIKU_BUILD_COMPATIBILITY_H __STRICT_ANSI__ ;
# set some additional defines
{
local defines =
FS_SHELL
;
if $(TARGET_PACKAGING_ARCH) = x86_gcc2 {
# GCC2 doesn't compile BFS correctly with -O2 or more
OPTIM = -O1 ;
}
defines = [ FDefines $(defines) ] ;
local c++flags = ;
if $(HOST_CC_IS_LEGACY_GCC) != 1 {
c++flags += -std=c++11 ;
}
SubDirCcFlags $(defines) -Wno-multichar ;
SubDirC++Flags $(defines) -Wno-multichar -fno-rtti ;
SubDirC++Flags $(defines) $(c++flags) -Wno-multichar -fno-rtti ;
}
# platform specific libraries
local fsShellCommandLibs ;
if ! $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
fsShellCommandLibs = $(HOST_NETWORK_LIBS) ;
}
UseHeaders [ FDirName $(HAIKU_TOP) headers build ] : true ;
if ! $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
UseHeaders [ FDirName $(HAIKU_TOP) headers build os ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) headers build os drivers ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) headers build os kernel ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) headers build os storage ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) headers build os support ] : true ;
}
UsePrivateHeaders shared storage ;
UsePrivateHeaders fs_shell ;
UseHeaders [ FDirName $(HAIKU_TOP) headers private ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src tools fs_shell ] ;
local fatSource =
attr.cpp
dir.cpp
dlist.cpp
dosfs.cpp
encodings.cpp
fat.cpp
file.cpp
iter.cpp
mkdos.cpp
util.cpp
vcache.cpp
version.cpp
;
BuildPlatformMergeObject <build>fatfs.o : $(fatSource) ;
BuildPlatformMain <build>fat_shell
: :
<build>fatfs.o
<build>fs_shell.a $(HOST_LIBSUPC++) $(HOST_LIBSTDC++)
$(HOST_LIBROOT) $(fsShellCommandLibs)
;
BuildPlatformMain <build>fat_fuse
: :
<build>fatfs.o
<build>fuse_module.a
$(HOST_LIBSUPC++) $(HOST_LIBSTDC++)
$(HOST_STATIC_LIBROOT) $(fsShellCommandLibs) fuse
;
SEARCH on [ FGristFiles DeviceOpener.cpp QueryParserUtils.cpp ]
+= [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems shared ] ;

View File

@ -27,8 +27,11 @@ fssh_recursive_lock_get_recursion(fssh_recursive_lock *lock)
extern "C" void
fssh_recursive_lock_init(fssh_recursive_lock *lock, const char *name)
fssh_recursive_lock_init_etc(fssh_recursive_lock *lock, const char *name,
uint32_t flags)
{
// TODO: No fssh_create_sem_etc for flags?
if (lock == NULL)
return;
@ -43,6 +46,13 @@ fssh_recursive_lock_init(fssh_recursive_lock *lock, const char *name)
}
extern "C" void
fssh_recursive_lock_init(fssh_recursive_lock *lock, const char *name)
{
fssh_recursive_lock_init_etc(lock, name, 0);
}
extern "C" void
fssh_recursive_lock_destroy(fssh_recursive_lock *lock)
{