Skip to content

Commit

Permalink
Applied updates and worked on Python bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz committed Nov 19, 2023
1 parent e359716 commit 9f8777c
Show file tree
Hide file tree
Showing 15 changed files with 1,570 additions and 98 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@ name: build
on: [push, pull_request]
permissions: read-all
jobs:
build_freebsd:
# FreeBSD support is provided via virtualization on MacOS 12
# See https://github.com/vmactions/freebsd-vm#under-the-hood.
runs-on: macos-12
steps:
- uses: actions/checkout@v3
- name: Building from source
id: build_freebsd
uses: vmactions/freebsd-vm@v0
with:
usesh: true
mem: 4096
# Note that the test scripts require bash
prepare: |
pkg install -y autoconf automake bash fusefs-libs gettext git libtool openssl pkgconf
run: |
tests/build.sh
tests/runtests.sh
build_ubuntu:
runs-on: ubuntu-22.04
strategy:
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/build_freebsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Build from source on FreeBSD.
name: build_freebsd
on: [push]
permissions: read-all
jobs:
build_freebsd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Building from source
id: build_freebsd
uses: vmactions/freebsd-vm@v1
with:
usesh: true
mem: 4096
# Note that the test scripts require bash
prepare: |
pkg install -y autoconf automake bash fusefs-libs gettext git libtool openssl pkgconf
run: |
tests/build.sh
tests/runtests.sh
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ install:
.\builddokan.ps1 -Configuration ${Configuration} -Platform "x64"; }
}
- sh: if test ${BUILD_ENVIRONMENT} = "python-tox" || test ${BUILD_ENVIRONMENT} = "xcode"; then brew update-reset && brew update -q; fi
- sh: if test ${BUILD_ENVIRONMENT} = "python-tox" || test ${BUILD_ENVIRONMENT} = "xcode"; then brew install -q autoconf automake gettext gnu-sed libtool openssl osxfuse pkg-config || true; fi
- sh: if test ${BUILD_ENVIRONMENT} = "python-tox" || test ${BUILD_ENVIRONMENT} = "xcode"; then brew install -q autoconf automake gettext gnu-sed libtool macfuse openssl pkg-config || true; fi
- sh: if test ${BUILD_ENVIRONMENT} = "python-tox"; then brew install -q python@${PYTHON_VERSION} tox twine-pypi || true; fi
- cmd: if [%BUILD_ENVIRONMENT%]==[python] (
"%PYTHON%" -m pip install -U pip setuptools twine wheel )
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ AC_PREREQ([2.71])

AC_INIT(
[libfsntfs],
[20231104],
[20231119],
[joachim.metz@gmail.com])

AC_CONFIG_SRCDIR(
Expand Down
6 changes: 3 additions & 3 deletions fsntfstools/info_handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ int info_handle_attribute_fprint(
}
fprintf(
info_handle->notify_stream,
"\tType\t\t\t\t: %s (0x%08" PRIx32 ")\n",
"\tAttribute type\t\t\t: %s (0x%08" PRIx32 ")\n",
info_handle_get_attribute_type_description(
attribute_type ),
attribute_type );
Expand Down Expand Up @@ -2160,7 +2160,7 @@ int info_handle_attribute_fprint(
}
fprintf(
info_handle->notify_stream,
"\tName\t\t\t: " );
"\tAttribute name\t\t: " );

if( info_handle_name_value_fprint(
info_handle,
Expand All @@ -2172,7 +2172,7 @@ int info_handle_attribute_fprint(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_PRINT_FAILED,
"%s: unable to print name string.",
"%s: unable to print attribute name string.",
function );

goto on_error;
Expand Down
4 changes: 2 additions & 2 deletions libfsntfs.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package >
<metadata>
<id>libfsntfs</id>
<version>20231104</version>
<version>20231119</version>
<authors>Joachim Metz</authors>
<owners>joachimmetz</owners>
<license type="expression">LGPL-3.0-or-later</license>
<projectUrl>https://github.com/libyal/libfsntfs</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<title>libfsntfs</title>
<description>Library to access the Windows New Technology File System (NTFS) format</description>
<releaseNotes>Release of libfsntfs 20231104</releaseNotes>
<releaseNotes>Release of libfsntfs 20231119</releaseNotes>
<copyright>Copyright (C) 2010-2023</copyright>
<tags>native</tags>
</metadata>
Expand Down
4 changes: 3 additions & 1 deletion manuals/libfsntfs.3
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.Dd July 28, 2022
.Dd November 19, 2023
.Dt libfsntfs 3
.Os libfsntfs
.Sh NAME
Expand Down Expand Up @@ -244,6 +244,8 @@ Attribute functions
.Fn libfsntfs_attribute_get_data_vcn_range "libfsntfs_attribute_t *attribute" "uint64_t *data_first_vcn" "uint64_t *data_last_vcn" "libfsntfs_error_t **error"
.Ft int
.Fn libfsntfs_attribute_get_data_size "libfsntfs_attribute_t *attribute" "size64_t *data_size" "libfsntfs_error_t **error"
.Ft int
.Fn libfsntfs_attribute_get_valid_data_size "libfsntfs_attribute_t *attribute" "size64_t *valid_data_size" "libfsntfs_error_t **error"
.Pp
$ATTRIBUTE_LIST attribute functions
.Ft int
Expand Down
130 changes: 130 additions & 0 deletions pyfsntfs/pyfsntfs_attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ PyMethodDef pyfsntfs_attribute_object_methods[] = {
"\n"
"Returns the name of the attribute." },

{ "get_data_size",
(PyCFunction) pyfsntfs_attribute_get_data_size,
METH_NOARGS,
"get_data_size() -> Integer\n"
"\n"
"Returns the size of the attribute data." },

{ "get_valid_data_size",
(PyCFunction) pyfsntfs_attribute_get_valid_data_size,
METH_NOARGS,
"get_valid_data_size() -> Integer\n"
"\n"
"Returns the size of the attribute data that is used (considered valid)." },

/* Sentinel */
{ NULL, NULL, 0, NULL }
};
Expand All @@ -70,6 +84,18 @@ PyGetSetDef pyfsntfs_attribute_object_get_set_definitions[] = {
"The name of the attribute.",
NULL },

{ "data_size",
(getter) pyfsntfs_attribute_get_data_size,
(setter) 0,
"The size of the attribute data.",
NULL },

{ "valid_data_size",
(getter) pyfsntfs_attribute_get_valid_data_size,
(setter) 0,
"The size of the attribute data that is used (considered valid).",
NULL },

/* Sentinel */
{ NULL, NULL, NULL, NULL, NULL }
};
Expand Down Expand Up @@ -488,3 +514,107 @@ PyObject *pyfsntfs_attribute_get_name(
return( NULL );
}

/* Retrieves the data size
* Returns a Python object if successful or NULL on error
*/
PyObject *pyfsntfs_attribute_get_data_size(
pyfsntfs_attribute_t *pyfsntfs_attribute,
PyObject *arguments PYFSNTFS_ATTRIBUTE_UNUSED )
{
libcerror_error_t *error = NULL;
PyObject *integer_object = NULL;
static char *function = "pyfsntfs_attribute_get_data_size";
size64_t data_size = 0;
int result = 0;

PYFSNTFS_UNREFERENCED_PARAMETER( arguments )

if( pyfsntfs_attribute == NULL )
{
PyErr_Format(
PyExc_ValueError,
"%s: invalid attribute.",
function );

return( NULL );
}
Py_BEGIN_ALLOW_THREADS

result = libfsntfs_attribute_get_data_size(
pyfsntfs_attribute->attribute,
&data_size,
&error );

Py_END_ALLOW_THREADS

if( result != 1 )
{
pyfsntfs_error_raise(
error,
PyExc_IOError,
"%s: unable to retrieve data size.",
function );

libcerror_error_free(
&error );

return( NULL );
}
integer_object = pyfsntfs_integer_unsigned_new_from_64bit(
(uint64_t) data_size );

return( integer_object );
}

/* Retrieves the valid data size
* Returns a Python object if successful or NULL on error
*/
PyObject *pyfsntfs_attribute_get_valid_data_size(
pyfsntfs_attribute_t *pyfsntfs_attribute,
PyObject *arguments PYFSNTFS_ATTRIBUTE_UNUSED )
{
libcerror_error_t *error = NULL;
PyObject *integer_object = NULL;
static char *function = "pyfsntfs_attribute_get_valid_data_size";
size64_t valid_data_size = 0;
int result = 0;

PYFSNTFS_UNREFERENCED_PARAMETER( arguments )

if( pyfsntfs_attribute == NULL )
{
PyErr_Format(
PyExc_ValueError,
"%s: invalid attribute.",
function );

return( NULL );
}
Py_BEGIN_ALLOW_THREADS

result = libfsntfs_attribute_get_valid_data_size(
pyfsntfs_attribute->attribute,
&valid_data_size,
&error );

Py_END_ALLOW_THREADS

if( result != 1 )
{
pyfsntfs_error_raise(
error,
PyExc_IOError,
"%s: unable to retrieve valid data size.",
function );

libcerror_error_free(
&error );

return( NULL );
}
integer_object = pyfsntfs_integer_unsigned_new_from_64bit(
(uint64_t) valid_data_size );

return( integer_object );
}

8 changes: 8 additions & 0 deletions pyfsntfs/pyfsntfs_attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@ PyObject *pyfsntfs_attribute_get_name(
pyfsntfs_attribute_t *pyfsntfs_attribute,
PyObject *arguments );

PyObject *pyfsntfs_attribute_get_data_size(
pyfsntfs_attribute_t *pyfsntfs_attribute,
PyObject *arguments );

PyObject *pyfsntfs_attribute_get_valid_data_size(
pyfsntfs_attribute_t *pyfsntfs_attribute,
PyObject *arguments );

#if defined( __cplusplus )
}
#endif
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ TESTS = \
$(TESTS_PYFSNTFS)

check_SCRIPTS = \
pyfsntfs_test_attribute.py \
pyfsntfs_test_file_entry.py \
pyfsntfs_test_support.py \
pyfsntfs_test_volume.py \
test_fsntfsinfo.sh \
Expand Down
Loading

0 comments on commit 9f8777c

Please sign in to comment.