Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e9fbcc9
Implement Tar APIs
carlossanlop Apr 13, 2022
0731cb2
Address some comment suggestions.
carlossanlop Apr 13, 2022
8f1f1af
Add SystemFormatsTarTestData package dependency entries and versions.
carlossanlop Apr 13, 2022
10df463
Merge the major and minor p/invokes into a single one.
carlossanlop Apr 14, 2022
da4af67
Address exception and nullability suggestions.
carlossanlop Apr 14, 2022
8710ceb
Adjust tests for the latest suggestions.
carlossanlop Apr 14, 2022
76e484c
Document elevation requirement to extract device files on Unix.
carlossanlop Apr 14, 2022
c9c4d85
Add tests to verify extraction without elevation throws for device fi…
carlossanlop Apr 14, 2022
e0dafda
Add separate expected mode for special files from assets (644).
carlossanlop Apr 14, 2022
5b8392b
Bump assets version to one with the fix
carlossanlop Apr 14, 2022
a16d4d9
Fix bugs and add tests for: timestamp conversion, extended attributes…
carlossanlop Apr 15, 2022
7ca674e
Validate entry.Name chars before extracting
carlossanlop Apr 15, 2022
560b789
Remove some minor todo comments
carlossanlop Apr 15, 2022
b3e5988
Add missing numeric value for PAL_S_IFCHR and its static assert
carlossanlop Apr 15, 2022
c22a8e7
Bug fixes:
carlossanlop Apr 16, 2022
d3e4f31
Bug fix: GNU can have two different metadata entries in a row if the …
carlossanlop Apr 16, 2022
23caa17
Add test to verify entry with subdir segments gets extracted by TarFi…
carlossanlop Apr 16, 2022
e0b0442
Rename UnknownFormat resource string to TarInvalidFormat, include for…
carlossanlop Apr 16, 2022
b682576
Bug fixes:
carlossanlop Apr 17, 2022
9fd01c3
Embed paths to exception message string when extracting file to diffe…
carlossanlop Apr 17, 2022
7b0d8c3
Bug fix: WriteEntry from file on Windows failing with V7 due to incom…
carlossanlop Apr 17, 2022
f1d9b7b
Bug fixes:
carlossanlop Apr 17, 2022
0980fbd
Use HAVE* in pal_io.c to detect library where makedev is available. D…
carlossanlop Apr 18, 2022
a28f3e5
Remove unnecessary TargetPlatformIdentifier override in src csproj.
carlossanlop Apr 18, 2022
7f2e516
Small refactor of VerifyOverwriteFileIsPossible
carlossanlop Apr 18, 2022
3f71b60
Remove parameter nullchecks.
carlossanlop Apr 18, 2022
cb855ed
Remove test method for attaching debugger.
carlossanlop Apr 18, 2022
dd40447
Remove devmajor and devminor duplicate todo message
carlossanlop Apr 18, 2022
9a28f12
Remove unused datetime method
carlossanlop Apr 19, 2022
40097c6
TMP exception with failed timestamp info
carlossanlop Apr 19, 2022
b1e8dfc
Remove failing device major/minor checks for now
carlossanlop Apr 19, 2022
c11e434
add FieldLocations static class, with position of first byte of each …
carlossanlop Apr 19, 2022
255ec96
Use InvariantCulture when converting the utf8 string to a double.
carlossanlop Apr 19, 2022
8ae7788
Copying file used by ExtractToDirectory test that throws, so it doesn…
carlossanlop Apr 19, 2022
d3cbdd2
Remove unused test method that opens and returns a filestream. We don…
carlossanlop Apr 19, 2022
6b5d078
Use a single rented buffer to read a whole header record. Convert rel…
carlossanlop Apr 19, 2022
19eb98d
Use ArrayPool for writing.
carlossanlop Apr 19, 2022
69ca3e7
Fix upper bound of DeviceMajor and DeviceMinor.
carlossanlop Apr 19, 2022
b1a2d5a
Remove async APIs from ref, comment them in src.
carlossanlop Apr 19, 2022
fb644dd
Add issue to TODO comments
carlossanlop Apr 19, 2022
cd40d62
Remove unused methods.
carlossanlop Apr 19, 2022
0ee2c33
Add InvariantCulture to double.ToString conversions.
carlossanlop Apr 19, 2022
58a3476
Fix test parsing a double, ensure it uses invariant culture.
carlossanlop Apr 20, 2022
fc0e568
More tests parsing a double, ensure invariant culture comparison.
carlossanlop Apr 20, 2022
5d81577
Verify link targets when extracting to directory. Disallow extracting…
carlossanlop Apr 20, 2022
a52dfe4
Avoid advancing stream anymore if end markers were found and GetNextE…
carlossanlop Apr 20, 2022
b227fa9
Add test that verifies stream is not advanced anymore after reading t…
carlossanlop Apr 20, 2022
5745b9f
Fix bug preventing correct generation of full path for extraction. Ad…
carlossanlop Apr 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use HAVE* in pal_io.c to detect library where makedev is available. D…
…o explicit casts to prevent build failures in wasm.

GetDeviceFiles p/invoke now returns int in case of error.
  • Loading branch information
carlossanlop committed Apr 18, 2022
commit 0980fbd6ccbf52378f3ac2006a6864413ae88c7f
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ internal static int CreateCharacterDevice(string pathName, uint mode, uint major
private static partial int MkNod(string pathName, uint mode, uint major, uint minor);

[LibraryImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetDeviceIdentifiers", SetLastError = true)]
internal static partial void GetDeviceIdentifiers(ulong dev, out uint major, out uint minor);
internal static unsafe partial int GetDeviceIdentifiers(ulong dev, uint* majorNumber, uint* minorNumber);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make dev argument type match type of FileStatus.Dev. Either use ulong or long for both.

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ partial void ReadFileFromDiskAndWriteToArchiveStreamAsEntry(string fullPath, str

if ((entryType is TarEntryType.BlockDevice or TarEntryType.CharacterDevice) && status.Dev > 0)
{
Interop.Sys.GetDeviceIdentifiers((ulong)status.Dev, out uint major, out uint minor);
uint major;
uint minor;
unsafe
{
Interop.CheckIo(Interop.Sys.GetDeviceIdentifiers((ulong)status.Dev, &major, &minor));
}

entry._header._devMajor = (int)major;
entry._header._devMinor = (int)minor;
}
Expand Down
2 changes: 2 additions & 0 deletions src/native/libs/Common/pal_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
#cmakedefine01 HAVE_MALLOC_USABLE_SIZE
#cmakedefine01 HAVE_MALLOC_USABLE_SIZE_NP
#cmakedefine01 HAVE_POSIX_MEMALIGN
#cmakedefine01 HAVE_MAKEDEV_FILEH
#cmakedefine01 HAVE_MAKEDEV_SYSMACROSH

// Mac OS X has stat64, but it is deprecated since plain stat now
// provides the same 64-bit aware struct when targeting OS X > 10.5
Expand Down
16 changes: 6 additions & 10 deletions src/native/libs/System.Native/pal_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#if !defined(TARGET_OSX) && !defined(TARGET_FREEBSD)
#if !HAVE_MAKEDEV_FILEH && HAVE_MAKEDEV_SYSMACROSH
#include <sys/sysmacros.h>
#endif
#include <sys/uio.h>
Expand Down Expand Up @@ -770,21 +770,17 @@ int32_t SystemNative_SymLink(const char* target, const char* linkPath)
return result;
}

void SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* major, uint32_t* minor)
int32_t SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* majorNumber, uint32_t* minorNumber)
{
dev_t castedDev = (dev_t)dev;
*major = major(castedDev);
*minor = minor(castedDev);
*majorNumber = (uint32_t)major(castedDev);
*minorNumber = (uint32_t)minor(castedDev);
return ConvertErrorPlatformToPal(errno);
}

int32_t SystemNative_MkNod(const char* pathName, uint32_t mode, uint32_t major, uint32_t minor)
{
#if defined(TARGET_WASM)
unsigned long long
#else
dev_t
#endif
dev = makedev(major, minor);
dev_t dev = (dev_t)makedev(major, minor);

if (errno > 0)
{
Expand Down
3 changes: 2 additions & 1 deletion src/native/libs/System.Native/pal_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,9 @@ PALEXPORT int32_t SystemNative_SymLink(const char* target, const char* linkPath)

/**
* Given a device ID, extracts the major and minor and components and returns them.
* Return 0 on success; otherwise, returns -1 and errno is set.
*/
PALEXPORT void SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* major, uint32_t* minor);
PALEXPORT int32_t SystemNative_GetDeviceIdentifiers(uint64_t dev, uint32_t* majorNumber, uint32_t* minorNumber);

/**
* Creates a special or ordinary file.
Expand Down
14 changes: 14 additions & 0 deletions src/native/libs/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,20 @@ check_c_source_compiles(
"
HAVE_BUILTIN_MUL_OVERFLOW)

check_symbol_exists(
makedev
sys/file.h
HAVE_MAKEDEV_FILEH)

check_symbol_exists(
makedev
sys/sysmacros.h
HAVE_MAKEDEV_SYSMACROSH)

if (NOT HAVE_MAKEDEV_FILEH AND NOT HAVE_MAKEDEV_SYSMACROSH)
message(FATAL_ERROR "Cannot find the makedev function on this platform.")
endif()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/Common/pal_config.h.in
${CMAKE_CURRENT_BINARY_DIR}/Common/pal_config.h)