Ticket #13513: 0002-Initialize-btrfs_shell.patch

File 0002-Initialize-btrfs_shell.patch, 13.1 KB (added by hyche, 3 years ago)
  • src/add-ons/kernel/file_systems/btrfs/Attribute.cpp

    From 2cf2bd0d2b98c790da07c75f39c2c06b94eb1641 Mon Sep 17 00:00:00 2001
    From: hyche <cvghy116@gmail.com>
    Date: Fri, 19 May 2017 15:36:28 +0700
    Subject: [PATCH 2/2] Initialize btrfs_shell: * Adding Jamfile in
     src/tools/btrfs_shell and include the subdir in src/tools/Jamfile * Adding
     system_dependencies.h in btrfs source to include all the system headers *
     fs_shell wrapping for btrfs source. If FS_SHELL is defined, compile with
     fs_shell headers instead. * Change macro BTRFS_SHELL to FS_SHELL * Adding
     btrfs_std_ops function: fs_shell now can recognize and load module
    
    ---
     .../kernel/file_systems/btrfs/Attribute.cpp        |  5 --
     .../file_systems/btrfs/AttributeIterator.cpp       |  3 --
     .../kernel/file_systems/btrfs/BPlusTree.cpp        |  5 --
     src/add-ons/kernel/file_systems/btrfs/BPlusTree.h  |  3 --
     src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp |  2 +-
     .../kernel/file_systems/btrfs/CachedBlock.h        |  1 -
     src/add-ons/kernel/file_systems/btrfs/Chunk.cpp    |  3 --
     .../file_systems/btrfs/DirectoryIterator.cpp       |  4 --
     src/add-ons/kernel/file_systems/btrfs/Inode.cpp    |  5 --
     src/add-ons/kernel/file_systems/btrfs/Inode.h      |  4 --
     src/add-ons/kernel/file_systems/btrfs/Volume.cpp   | 12 -----
     src/add-ons/kernel/file_systems/btrfs/Volume.h     |  1 -
     src/add-ons/kernel/file_systems/btrfs/btrfs.h      |  6 +--
     .../kernel/file_systems/btrfs/crc_table.cpp        |  3 +-
     .../kernel/file_systems/btrfs/kernel_interface.cpp | 55 +++++++++++++++------
     .../file_systems/btrfs/system_dependencies.h       | 45 +++++++++++++++++
     src/tools/Jamfile                                  |  1 +
     src/tools/btrfs_shell/Jamfile                      | 57 ++++++++++++++++++++++
     18 files changed, 147 insertions(+), 68 deletions(-)
     create mode 100644 src/add-ons/kernel/file_systems/btrfs/system_dependencies.h
     create mode 100644 src/tools/btrfs_shell/Jamfile
    
    diff --git a/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp b/src/add-ons/kernel/file_systems/btrfs/Attribute.cpp
    index a73a54d..3553005 100644
    a b  
    99
    1010
    1111#include "Attribute.h"
    12 
    13 #include <new>
    14 #include <stdio.h>
    15 #include <stdlib.h>
    16 
    1712#include "BPlusTree.h"
    1813#include "CRCTable.h"
    1914#include "Utility.h"
  • src/add-ons/kernel/file_systems/btrfs/AttributeIterator.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.cpp b/src/add-ons/kernel/file_systems/btrfs/AttributeIterator.cpp
    index 7601944..3b67e83 100644
    a b  
    66
    77#include "AttributeIterator.h"
    88
    9 #include <new>
    10 #include <stdlib.h>
    11 
    129
    1310//#define TRACE_BTRFS
    1411#ifdef TRACE_BTRFS
  • src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp b/src/add-ons/kernel/file_systems/btrfs/BPlusTree.cpp
    index 2128c0c..af8a031 100644
    a b  
    99
    1010
    1111#include "BPlusTree.h"
    12 
    1312#include "CachedBlock.h"
    1413
    15 #include <stdlib.h>
    16 #include <string.h>
    17 #include <util/AutoLock.h>
    18 
    1914
    2015//#define TRACE_BTRFS
    2116#ifdef TRACE_BTRFS
  • src/add-ons/kernel/file_systems/btrfs/BPlusTree.h

    diff --git a/src/add-ons/kernel/file_systems/btrfs/BPlusTree.h b/src/add-ons/kernel/file_systems/btrfs/BPlusTree.h
    index 7f7babe..a9e7ee2 100644
    a b  
    88
    99
    1010#include "btrfs.h"
    11 
    12 #include <util/SinglyLinkedList.h>
    13 
    1411#include "Volume.h"
    1512
    1613
  • src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp b/src/add-ons/kernel/file_systems/btrfs/CRCTable.cpp
    index 0c5736c..b621f75 100644
    a b  
    77 */
    88
    99
    10 #include <SupportDefs.h>
     10#include "system_dependencies.h"
    1111
    1212
    1313//! CRC 03667067501 table, as generated by crc_table.cpp
  • src/add-ons/kernel/file_systems/btrfs/CachedBlock.h

    diff --git a/src/add-ons/kernel/file_systems/btrfs/CachedBlock.h b/src/add-ons/kernel/file_systems/btrfs/CachedBlock.h
    index 1fafbb4..59ff119 100644
    a b  
    77
    88//! interface for the block cache
    99
    10 #include <fs_cache.h>
    1110
    1211#include "Volume.h"
    1312
  • src/add-ons/kernel/file_systems/btrfs/Chunk.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp b/src/add-ons/kernel/file_systems/btrfs/Chunk.cpp
    index 3d804d5..9ce7003 100644
    a b  
    99
    1010#include "Chunk.h"
    1111
    12 #include <stdlib.h>
    13 #include <string.h>
    14 
    1512
    1613//#define TRACE_BTRFS
    1714#ifdef TRACE_BTRFS
  • src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/btrfs/DirectoryIterator.cpp
    index 62241e6..ded0351 100644
    a b  
    55
    66
    77#include "DirectoryIterator.h"
    8 
    9 #include <new>
    10 #include <stdlib.h>
    11 
    128#include "CRCTable.h"
    139
    1410
  • src/add-ons/kernel/file_systems/btrfs/Inode.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/Inode.cpp b/src/add-ons/kernel/file_systems/btrfs/Inode.cpp
    index 0932acd..666000e 100644
    a b  
    77
    88
    99#include "Inode.h"
    10 
    11 #include <string.h>
    12 #include <stdlib.h>
    13 #include <zlib.h>
    14 
    1510#include "BPlusTree.h"
    1611#include "CachedBlock.h"
    1712#include "Utility.h"
  • src/add-ons/kernel/file_systems/btrfs/Inode.h

    diff --git a/src/add-ons/kernel/file_systems/btrfs/Inode.h b/src/add-ons/kernel/file_systems/btrfs/Inode.h
    index 0213e88..683ae03 100644
    a b  
    77#define INODE_H
    88
    99
    10 #include <fs_cache.h>
    11 #include <lock.h>
    12 #include <string.h>
    13 
    1410#include "btrfs.h"
    1511#include "Volume.h"
    1612
  • src/add-ons/kernel/file_systems/btrfs/Volume.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/Volume.cpp b/src/add-ons/kernel/file_systems/btrfs/Volume.cpp
    index 6f44df5..1886041 100644
    a b  
    99
    1010
    1111#include "Volume.h"
    12 
    13 #include <errno.h>
    14 #include <new>
    15 #include <stdio.h>
    16 #include <stdlib.h>
    17 #include <string.h>
    18 
    19 #include <fs_cache.h>
    20 #include <fs_volume.h>
    21 
    22 #include <util/AutoLock.h>
    23 
    2412#include "BPlusTree.h"
    2513#include "CachedBlock.h"
    2614#include "Chunk.h"
  • src/add-ons/kernel/file_systems/btrfs/Volume.h

    diff --git a/src/add-ons/kernel/file_systems/btrfs/Volume.h b/src/add-ons/kernel/file_systems/btrfs/Volume.h
    index dabdca5..1171a25 100644
    a b  
    66#ifndef VOLUME_H
    77#define VOLUME_H
    88
    9 #include <lock.h>
    109
    1110#include "btrfs.h"
    1211
  • src/add-ons/kernel/file_systems/btrfs/btrfs.h

    diff --git a/src/add-ons/kernel/file_systems/btrfs/btrfs.h b/src/add-ons/kernel/file_systems/btrfs/btrfs.h
    index ef2a69c..2791cf2 100644
    a b  
    66#define BTRFS_H
    77
    88
    9 #include <sys/stat.h>
    10 
    11 #include <ByteOrder.h>
    12 #include <fs_interface.h>
    13 #include <KernelExport.h>
     9#include "system_dependencies.h"
    1410
    1511
    1612typedef uint64 fileblock_t;     // file block number
  • src/add-ons/kernel/file_systems/btrfs/crc_table.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/crc_table.cpp b/src/add-ons/kernel/file_systems/btrfs/crc_table.cpp
    index 1413f95..e35f217 100644
    a b  
    1717*/
    1818
    1919
    20 #include <stdio.h>
    21 #include <sys/types.h>
     20#include "system_dependencies.h"
    2221
    2322
    2423typedef unsigned int uint32 ;
  • src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp

    diff --git a/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/btrfs/kernel_interface.cpp
    index 303d416..c405125 100644
    a b  
    55 */
    66
    77
    8 #include <dirent.h>
    9 #include <util/kernel_cpp.h>
    10 #include <string.h>
    11 
    12 #include <AutoDeleter.h>
    13 #include <fs_cache.h>
    14 #include <fs_info.h>
    15 #include <io_requests.h>
    16 #include <NodeMonitor.h>
    17 #include <util/AutoLock.h>
    18 
    198#include "Attribute.h"
    209#include "AttributeIterator.h"
    2110#include "btrfs.h"
    btrfs_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request  
    266255    Volume* volume = (Volume*)_volume->private_volume;
    267256    Inode* inode = (Inode*)_node->private_node;
    268257
    269 #ifndef BTRFS_SHELL
     258#ifndef FS_SHELL
    270259    if (io_request_is_write(request) && volume->IsReadOnly()) {
    271260        notify_io_request(request, B_READ_ONLY_DEVICE);
    272261        return B_READ_ONLY_DEVICE;
    btrfs_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request  
    274263#endif
    275264
    276265    if (inode->FileCache() == NULL) {
    277 #ifndef BTRFS_SHELL
     266#ifndef FS_SHELL
    278267        notify_io_request(request, B_BAD_VALUE);
    279268#endif
    280269        return B_BAD_VALUE;
    btrfs_remove_attr(fs_volume* _volume, fs_vnode* vnode,  
    752741    return EROFS;
    753742}
    754743
     744//  #pragma mark -
     745
     746
     747static status_t
     748btrfs_std_ops(int32 op, ...)
     749{
     750    switch (op) {
     751        case B_MODULE_INIT:
     752            return B_OK;
     753        case B_MODULE_UNINIT:
     754            return B_OK;
     755
     756        default:
     757            return B_ERROR;
     758    }
     759}
     760
    755761
    756762fs_volume_ops gBtrfsVolumeOps = {
    757763    &btrfs_unmount,
    static file_system_module_info sBtrfsFileSystem = {  
    839845    {
    840846        "file_systems/btrfs" B_CURRENT_FS_API_VERSION,
    841847        0,
    842         NULL,
     848        btrfs_std_ops,
    843849    },
    844850
    845851    "btrfs",                        // short_name
    static file_system_module_info sBtrfsFileSystem = {  
    854860
    855861    &btrfs_mount,
    856862
     863   
     864    /* capability querying operations */
    857865    NULL,
     866
     867    NULL,   // validate_resize
     868    NULL,   // validate_move
     869    NULL,   // validate_set_content_name
     870    NULL,   // validate_set_content_parameters
     871    NULL,   // validate_initialize,
     872
     873    /* shadow partition modification */
     874    NULL,   // shadow_changed
     875
     876    /* writing */
     877    NULL,   // defragment
     878    NULL,   // repair
     879    NULL,   // resize
     880    NULL,   // move
     881    NULL,   // set_content_name
     882    NULL,   // set_content_parameters
     883    NULL,   // initialize
     884    NULL    // unitialize
    858885};
    859886
    860887
  • new file src/add-ons/kernel/file_systems/btrfs/system_dependencies.h

    diff --git a/src/add-ons/kernel/file_systems/btrfs/system_dependencies.h b/src/add-ons/kernel/file_systems/btrfs/system_dependencies.h
    new file mode 100644
    index 0000000..dd337be
    - +  
     1#ifndef _SYSTEM_DEPENDENCIES_H
     2#define _SYSTEM_DEPENDENCIES_H
     3
     4
     5#ifdef FS_SHELL
     6
     7// This needs to be included before the fs_shell wrapper
     8#include <zlib.h>
     9#include <new>
     10
     11#include "fssh_api_wrapper.h"
     12#include "fssh_auto_deleter.h"
     13
     14#else   // !FS_SHELL
     15
     16#include <AutoDeleter.h>
     17#include <util/kernel_cpp.h>
     18#include <util/AutoLock.h>
     19#include <util/SinglyLinkedList.h>
     20#include <util/Stack.h>
     21#include <sys/stat.h>
     22#include <sys/types.h>
     23#include <ByteOrder.h>
     24#include <fs_cache.h>
     25#include <fs_interface.h>
     26#include <fs_info.h>
     27#include <fs_volume.h>
     28#include <KernelExport.h>
     29#include <io_requests.h>
     30#include <NodeMonitor.h>
     31#include <SupportDefs.h>
     32#include <lock.h>
     33#include <errno.h>
     34#include <new>
     35#include <dirent.h>
     36#include <string.h>
     37#include <stdio.h>
     38#include <stdlib.h>
     39#include <unistd.h>
     40#include <zlib.h>
     41
     42#endif  // !FS_SHELL
     43
     44
     45#endif  // _SYSTEM_DEPENDENCIES
  • src/tools/Jamfile

    diff --git a/src/tools/Jamfile b/src/tools/Jamfile
    index 680646e..699c766 100644
    a b SEARCH on [ FGristFiles  
    8888SubInclude HAIKU_TOP src tools addattr ;
    8989SubInclude HAIKU_TOP src tools anyboot ;
    9090SubInclude HAIKU_TOP src tools bfs_shell ;
     91SubInclude HAIKU_TOP src tools btrfs_shell ;
    9192SubInclude HAIKU_TOP src tools cppunit ;
    9293SubInclude HAIKU_TOP src tools create_repository_config ;
    9394SubInclude HAIKU_TOP src tools elfsymbolpatcher ;
  • new file src/tools/btrfs_shell/Jamfile

    diff --git a/src/tools/btrfs_shell/Jamfile b/src/tools/btrfs_shell/Jamfile
    new file mode 100644
    index 0000000..9f46bb3
    - +  
     1SubDir HAIKU_TOP src tools btrfs_shell ;
     2
     3SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src add-ons kernel file_systems btrfs ] ;
     4
     5# prevent inclusion of HaikuBuildCompatibility.h
     6DEFINES += HAIKU_BUILD_COMPATIBILITY_H ;
     7
     8# set some additional defines
     9{
     10    local defines =
     11        #BTRFS_BIG_ENDIAN_ONLY
     12        FS_SHELL
     13        TRACE_BTRFS # ENABLE DEBUGGING
     14        ;
     15
     16    defines = [ FDefines $(defines) ] ;
     17    SubDirCcFlags $(defines) -Wno-multichar ;
     18    SubDirC++Flags $(defines) -Wno-multichar -fno-rtti ;
     19    HOST_LINKFLAGS += -lz ; # zlib link
     20}
     21
     22
     23# platform specific libraries
     24local fsShellCommandLibs ;
     25if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
     26    fsShellCommandLibs = $(HOST_NETWORK_LIBS) ;
     27}
     28
     29if ! $(HOST_PLATFORM_BEOS_COMPATIBLE) {
     30    UseHeaders [ FDirName $(HAIKU_TOP) headers build os ] : true ;
     31}
     32
     33UsePrivateHeaders shared storage fs_shell ;
     34UseHeaders [ FDirName $(HAIKU_TOP) headers private ] : true ;
     35UseHeaders [ FDirName $(HAIKU_TOP) src tools fs_shell ] ;
     36
     37local btrfsSources =
     38    Attribute.cpp
     39    AttributeIterator.cpp
     40    BPlusTree.cpp
     41    Chunk.cpp
     42    CRCTable.cpp
     43    DirectoryIterator.cpp
     44    Inode.cpp
     45    Volume.cpp
     46    kernel_interface.cpp
     47;
     48
     49BuildPlatformMergeObject <build>btrfs.o : $(btrfsSources) ;
     50
     51BuildPlatformMain <build>btrfs_shell
     52    :
     53    :
     54    <build>btrfs.o
     55    <build>fs_shell.a $(libHaikuCompat) $(HOST_LIBSUPC++) $(HOST_LIBSTDC++)
     56    $(HOST_LIBROOT) $(fsShellCommandLibs)
     57;