* Made the iso9660 file system buildable within the fs_shell (iso9660_shell).

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30639 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-05-05 20:07:24 +00:00
parent ce34c0c260
commit f47bff0880
11 changed files with 149 additions and 146 deletions
@@ -9,18 +9,21 @@
#include "iso9660.h" #include "iso9660.h"
#include <ctype.h> #include <ctype.h>
#include <dirent.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <ByteOrder.h> #ifndef FS_SHELL
#include <Drivers.h> # include <dirent.h>
#include <KernelExport.h> # include <fcntl.h>
#include <fs_cache.h> # include <stdlib.h>
# include <string.h>
# include <sys/stat.h>
# include <time.h>
# include <unistd.h>
# include <ByteOrder.h>
# include <Drivers.h>
# include <KernelExport.h>
# include <fs_cache.h>
#endif
#include "rock_ridge.h" #include "rock_ridge.h"
@@ -98,8 +101,8 @@ unicode_to_utf8(const char *src, int32 *srcLen, char *dst, int32 *dstLen)
for (srcCount = 0; srcCount < srcLimit; srcCount += 2) { for (srcCount = 0; srcCount < srcLimit; srcCount += 2) {
uint16 *UNICODE = (uint16 *)&src[srcCount]; uint16 *UNICODE = (uint16 *)&src[srcCount];
uchar utf8[4]; uint8 utf8[4];
uchar *UTF8 = utf8; uint8 *UTF8 = utf8;
int32 utf8Len; int32 utf8Len;
int32 j; int32 j;
@@ -8,15 +8,19 @@
#define ISO_9660_H #define ISO_9660_H
#include "lock.h" #if FS_SHELL
# include "fssh_api_wrapper.h"
#else
# include <stdio.h>
# include <sys/types.h>
# include <time.h>
# include <endian.h>
#include <fs_interface.h> # include <fs_interface.h>
#include <SupportDefs.h> # include <SupportDefs.h>
#include <stdio.h> # include <lock.h>
#include <sys/types.h> #endif
#include <time.h>
#include <endian.h>
// Size of primary volume descriptor for ISO9660 // Size of primary volume descriptor for ISO9660
@@ -1,5 +1,5 @@
/* /*
* Copyright 2007, Axel Dörfler, [email protected]. * Copyright 2007-2009, Axel Dörfler, [email protected].
* Copyright 2002, Tyler Dauwalder. * Copyright 2002, Tyler Dauwalder.
* *
* This file may be used under the terms of the MIT License. * This file may be used under the terms of the MIT License.
@@ -33,27 +33,29 @@
- 0x003A == ':' - 0x003A == ':'
- 0x003B == ';' - 0x003B == ';'
- 0x003F == '?' - 0x003F == '?'
- 0x005C == '\' - 0x005C == '\'
*/ */
#include "iso9660_identify.h" #include "iso9660_identify.h"
#include <errno.h> #ifndef FS_SHELL
#include <stdlib.h> # include <errno.h>
#include <string.h> # include <stdlib.h>
#include <unistd.h> # include <string.h>
#include <stdio.h> # include <unistd.h>
# include <stdio.h>
#include <ByteOrder.h> # include <ByteOrder.h>
#include <fs_info.h> # include <fs_info.h>
#include <KernelExport.h> # include <KernelExport.h>
#endif
#include "iso9660.h" #include "iso9660.h"
//#define TRACE(x) ; //#define TRACE(x) ;
#define TRACE(x) dprintf x #define TRACE(x) dprintf x
// misc constants
static const char *kISO9660Signature = "CD001"; static const char *kISO9660Signature = "CD001";
static const uint32 kVolumeDescriptorLength = 2048; static const uint32 kVolumeDescriptorLength = 2048;
#define ISO9660_VOLUME_IDENTIFIER_LENGTH 32 #define ISO9660_VOLUME_IDENTIFIER_LENGTH 32
@@ -72,18 +74,18 @@ typedef enum {
descriptor types. descriptor types.
*/ */
typedef struct iso9660_common_descriptor { typedef struct iso9660_common_descriptor {
uchar type; uint8 type;
char standard_identifier[5]; // should be 'CD001' char standard_identifier[5]; // should be 'CD001'
uchar version; uint8 version;
// Remaining bytes are unused // Remaining bytes are unused
} __attribute__((packed)) iso9660_common_volume_descriptor; } __attribute__((packed)) iso9660_common_volume_descriptor;
typedef struct iso9660_volume_descriptor { typedef struct iso9660_volume_descriptor {
iso9660_common_descriptor common; iso9660_common_descriptor common;
uchar flags; uint8 flags;
char system_identifier[32]; char system_identifier[32];
char identifier[ISO9660_VOLUME_IDENTIFIER_LENGTH]; char identifier[ISO9660_VOLUME_IDENTIFIER_LENGTH];
uchar _reserved0[8]; uint8 _reserved0[8];
uint32 size; uint32 size;
uint32 size_big_endian; uint32 size_big_endian;
char escape_sequences[ISO9660_ESCAPE_SEQUENCE_LENGTH]; char escape_sequences[ISO9660_ESCAPE_SEQUENCE_LENGTH];
@@ -97,7 +99,7 @@ typedef struct iso9660_volume_descriptor {
uint32 path_table_size; uint32 path_table_size;
uint32 path_table_size_big_endian; uint32 path_table_size_big_endian;
uint32 _reserved1[4]; uint32 _reserved1[4];
uchar root_directory_record[34]; uint8 root_directory_record[34];
char set_identifier[28]; char set_identifier[28];
// Remaining bytes are disinteresting to us // Remaining bytes are disinteresting to us
} __attribute__((packed)) iso9660_volume_descriptor; } __attribute__((packed)) iso9660_volume_descriptor;
@@ -108,7 +110,7 @@ typedef struct iso9660_directory_record {
uint32 location; uint32 location;
uint32 location_big_endian; uint32 location_big_endian;
uint32 data_length; uint32 data_length;
uchar _reserved[14]; uint8 _reserved[14];
uint16 volume_space; uint16 volume_space;
} __attribute__((packed)) iso9660_directory_record; } __attribute__((packed)) iso9660_directory_record;
@@ -199,10 +201,10 @@ iso9660_info::_SetString(char **string, const char *newString,
if (string == NULL) if (string == NULL)
return; return;
TRACE(("iso9660_info::set_string(%p ('%s'), '%s', %ld)\n", string, TRACE(("iso9660_info::set_string(%p ('%s'), '%s', %u)\n", string,
*string, newString, newLength)); *string, newString, (unsigned)newLength));
char *&oldString = *string; char *&oldString = *string;
free(oldString); free(oldString);
if (newString) { if (newString) {
@@ -213,7 +215,7 @@ iso9660_info::_SetString(char **string, const char *newString,
} }
} else } else
oldString = NULL; oldString = NULL;
} }
// #pragma mark - C functions // #pragma mark - C functions
@@ -293,16 +295,16 @@ dump_primary_descriptor(iso9660_volume_descriptor *primary,
dump_common_descriptor(&primary->common, indent, false); dump_common_descriptor(&primary->common, indent, false);
TRACE(("%s identifier: '%.32s'\n", indent, TRACE(("%s identifier: '%.32s'\n", indent,
primary->identifier)); primary->identifier));
TRACE(("%s size: %ld\n", indent, TRACE(("%s size: %d\n", indent,
B_LENDIAN_TO_HOST_INT32(primary->size))); (int)B_LENDIAN_TO_HOST_INT32(primary->size)));
TRACE(("%s set size: %ld\n", indent, TRACE(("%s set size: %d\n", indent,
B_LENDIAN_TO_HOST_INT32(primary->set_size))); (int)B_LENDIAN_TO_HOST_INT32(primary->set_size)));
TRACE(("%s sequence number: %ld\n", indent, TRACE(("%s sequence number: %d\n", indent,
B_LENDIAN_TO_HOST_INT32(primary->sequence_number))); (int)B_LENDIAN_TO_HOST_INT32(primary->sequence_number)));
TRACE(("%s logical block size: %ld\n", indent, TRACE(("%s logical block size: %d\n", indent,
B_LENDIAN_TO_HOST_INT32(primary->logical_block_size))); (int)B_LENDIAN_TO_HOST_INT32(primary->logical_block_size)));
TRACE(("%s path table size: %ld\n", indent, TRACE(("%s path table size: %d\n", indent,
B_LENDIAN_TO_HOST_INT32(primary->path_table_size))); (int)B_LENDIAN_TO_HOST_INT32(primary->path_table_size)));
TRACE(("%s set identifier: %.28s\n", indent, TRACE(("%s set identifier: %.28s\n", indent,
primary->set_identifier)); primary->set_identifier));
dump_directory_record((iso9660_directory_record*) dump_directory_record((iso9660_directory_record*)
@@ -333,10 +335,10 @@ dump_directory_record(iso9660_directory_record *record, const char *indent)
{ {
TRACE(("%s root directory record:\n", indent)); TRACE(("%s root directory record:\n", indent));
TRACE(("%s length: %d\n", indent, record->length)); TRACE(("%s length: %d\n", indent, record->length));
TRACE(("%s location: %ld\n", indent, TRACE(("%s location: %d\n", indent,
B_LENDIAN_TO_HOST_INT32(record->location))); (int)B_LENDIAN_TO_HOST_INT32(record->location)));
TRACE(("%s data length: %ld\n", indent, TRACE(("%s data length: %d\n", indent,
B_LENDIAN_TO_HOST_INT32(record->data_length))); (int)B_LENDIAN_TO_HOST_INT32(record->data_length)));
TRACE(("%s volume space: %d\n", indent, TRACE(("%s volume space: %d\n", indent,
B_LENDIAN_TO_HOST_INT16(record->volume_space))); B_LENDIAN_TO_HOST_INT16(record->volume_space)));
} }
@@ -360,7 +362,7 @@ check_common_descriptor(iso9660_common_descriptor *common)
/*! \brief Returns true if the given partition is a valid iso9660 partition. /*! \brief Returns true if the given partition is a valid iso9660 partition.
See fs_identify_hook() for more information. See fs_identify_hook() for more information.
\todo Fill in partitionInfo->mounted_at with something useful. \todo Fill in partitionInfo->mounted_at with something useful.
*/ */
status_t status_t
@@ -480,7 +482,7 @@ iso9660_fs_identify(int deviceFD, iso9660_info *info)
name, info->joliet_name)); name, info->joliet_name));
} }
info->SetJolietName(name, pos - name); info->SetJolietName(name, pos - name);
} }
break; break;
} }
@@ -495,7 +497,7 @@ iso9660_fs_identify(int deviceFD, iso9660_info *info)
default: default:
break; break;
} }
} }
return found ? B_OK : error; return found ? B_OK : error;
} }
@@ -1,4 +1,4 @@
/* /*
* Copyright 2007, Axel Dörfler, [email protected]. * Copyright 2007, Axel Dörfler, [email protected].
* Copyright 2002, Tyler Dauwalder. * Copyright 2002, Tyler Dauwalder.
* *
@@ -8,7 +8,11 @@
#define ISO9660_IDENTIFY_H #define ISO9660_IDENTIFY_H
#include <SupportDefs.h> #if FS_SHELL
# include "fssh_api_wrapper.h"
#else
# include <SupportDefs.h>
#endif
/*! \brief Contains all the info of interest pertaining to an /*! \brief Contains all the info of interest pertaining to an
@@ -9,28 +9,31 @@
#include <ctype.h> #include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include <KernelExport.h> #ifndef FS_SHELL
#include <NodeMonitor.h> # include <dirent.h>
#include <fs_interface.h> # include <errno.h>
#include <fs_cache.h> # include <fcntl.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <sys/stat.h>
# include <time.h>
# include <unistd.h>
#include <fs_attr.h> # include <KernelExport.h>
#include <fs_info.h> # include <NodeMonitor.h>
#include <fs_index.h> # include <fs_interface.h>
#include <fs_query.h> # include <fs_cache.h>
#include <fs_volume.h>
#include <util/kernel_cpp.h> # include <fs_attr.h>
# include <fs_info.h>
# include <fs_index.h>
# include <fs_query.h>
# include <fs_volume.h>
# include <util/kernel_cpp.h>
#endif
#include "iso9660.h" #include "iso9660.h"
#include "iso9660_identify.h" #include "iso9660_identify.h"
@@ -285,7 +288,7 @@ fs_walk(fs_volume *_vol, fs_vnode *_base, const char *file, ino_t *_vnodeID)
} else { } else {
result = initResult; result = initResult;
if (bytesRead == 0) if (bytesRead == 0)
done = TRUE; done = true;
} }
blockData += bytesRead; blockData += bytesRead;
blockBytesRead += bytesRead; blockBytesRead += bytesRead;
@@ -302,7 +305,7 @@ fs_walk(fs_volume *_vol, fs_vnode *_base, const char *file, ino_t *_vnodeID)
block_cache_put(ns->fBlockCache, cachedBlock); block_cache_put(ns->fBlockCache, cachedBlock);
} else } else
done = TRUE; done = true;
} }
TRACE(("fs_walk - EXIT, result is %s, vnid is %Lu\n", TRACE(("fs_walk - EXIT, result is %s, vnid is %Lu\n",
@@ -2,26 +2,31 @@
Copyright 1999, Be Incorporated. All Rights Reserved. Copyright 1999, Be Incorporated. All Rights Reserved.
This file may be used under the terms of the Be Sample Code License. This file may be used under the terms of the Be Sample Code License.
*/ */
#ifndef ROCK_RIDGE_H
#define ROCK_RIDGE_H
// Altername name field flags. // Altername name field flags.
enum { enum NMFLAGS {
NM_CONTINUE = 1, NM_CONTINUE = 1,
NM_CURRENT = 2, NM_CURRENT = 2,
NM_PARENT = 4, NM_PARENT = 4,
NM_HOST = 32 NM_HOST = 32
} NMFLAGS; };
// Symbolic link field flags // Symbolic link field flags
enum { enum SLFLAGS {
SL_CONTINUE = 1 SL_CONTINUE = 1
} SLFLAGS; };
// Symbolic link field component flags // Symbolic link field component flags
enum { enum SLCPFLAGS {
SLCP_CONTINUE = 1, SLCP_CONTINUE = 1,
SLCP_CURRENT = 2, SLCP_CURRENT = 2,
SLCP_PARENT = 4, SLCP_PARENT = 4,
SLCP_ROOT = 8, SLCP_ROOT = 8,
SLCP_VOLROOT = 16, SLCP_VOLROOT = 16,
SLCP_HOST = 32 SLCP_HOST = 32
} SLCPFLAGS; };
#endif // ROCK_RIDGE_H
+10 -10
View File
@@ -1,12 +1,12 @@
SubDir HAIKU_TOP src tests add-ons kernel file_systems ; SubDir HAIKU_TOP src tests add-ons kernel file_systems ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems bfs ; HaikuSubInclude bfs ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems cdda ; HaikuSubInclude cdda ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems consistency_check ; HaikuSubInclude consistency_check ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems fs_shell ; HaikuSubInclude fs_shell ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems fragmenter ; HaikuSubInclude fragmenter ;
#SubInclude HAIKU_TOP src tests add-ons kernel file_systems iso9660 ; HaikuSubInclude iso9660 ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems random_file_actions ; HaikuSubInclude random_file_actions ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems random_read ; HaikuSubInclude random_read ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems udf ; HaikuSubInclude udf ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems userlandfs ; HaikuSubInclude userlandfs ;
@@ -1,3 +1,3 @@
SubDir HAIKU_TOP src tests add-ons kernel file_systems iso9660 ; SubDir HAIKU_TOP src tests add-ons kernel file_systems iso9660 ;
SubInclude HAIKU_TOP src tests add-ons kernel file_systems iso9660 iso9660_shell ; HaikuSubInclude iso9660_shell ;
@@ -1,31 +1,34 @@
SubDir HAIKU_TOP src tests add-ons kernel file_systems iso9660 iso9660_shell ; SubDir HAIKU_TOP src tests add-ons kernel file_systems iso9660 iso9660_shell ;
SubDirHdrs $(HAIKU_TOP) src add-ons kernel file_systems iso9660 ; UsePrivateHeaders fs_shell ;
SubDirHdrs $(HAIKU_TOP) src tests add-ons kernel file_systems fs_shell ;
SEARCH_SOURCE
+= [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems iso9660 ] ;
# set some additional defines
{ {
local defines = [ FDefines USER DEBUG ] ; # _NO_INLINE_ASM local defines = [ FDefines FS_SHELL USER DEBUG ] ;
SubDirCcFlags $(defines) -fno-exceptions -fno-rtti ; #-fcheck-memory-usage SubDirCcFlags $(defines) -Wall -Wno-multichar ;
SubDirC++Flags $(defines) -Wall -Wno-multichar -fno-exceptions ;
} }
local fsShellSources = local libHaikuCompat ;
fsh.c rootfs.c initfs.c kernel.c cache.c external_commands.cpp sl.c if $(HOST_PLATFORM_BEOS_COMPATIBLE) && ! $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
stub.c tracker.cpp sysdep.c hexdump.c argv.c libHaikuCompat = libhaikucompat_build.a ;
}
# platform specific libraries
local fsShellCommandLibs ;
if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
fsShellCommandLibs = $(HOST_NETWORK_LIBS) ;
}
BuildPlatformMain iso9660_shell
:
iso9660.cpp
iso9660_identify.cpp
kernel_interface.cpp
: <build>fs_shell.a $(libHaikuCompat) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++)
$(HOST_LIBROOT) $(fsShellCommandLibs)
; ;
SimpleTest iso9660_shell
:
$(fsShellSources)
iso.c kernel_interface.c
:
;
# Tell Jam where to find these sources
SEARCH on [ FGristFiles
iso.c kernel_interface.c
] = [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems iso9660 ] ;
SEARCH on [ FGristFiles
$(fsShellSources)
] = [ FDirName $(HAIKU_TOP) src tests add-ons kernel file_systems fs_shell ] ;
@@ -1,12 +0,0 @@
/* This file is included in fs_shell:fsh.c
* Insert your implementation of additional commands in here
*
* Format:
*
* static void
* function(int argc, char **argv)
* {
* }
*
*/
@@ -1,9 +0,0 @@
/* This file is included in fs_shell:fsh.c
* Insert your definition of additional commands here
*
* Format:
* { commandName, functionName, commandDescription },
*
* And don't forget the comma after the line :-)
*/