HDFS-7879. hdfs.dll does not export functions of the public libhdfs API. Contributed by Chris Nauroth.

This commit is contained in:
Haohui Mai 2015-03-04 09:17:21 -08:00
parent 3560180b6e
commit f717dc51b2
3 changed files with 111 additions and 7 deletions

View File

@ -1086,6 +1086,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7869. Inconsistency in the return information while performing rolling HDFS-7869. Inconsistency in the return information while performing rolling
upgrade ( J.Andreina via vinayakumarb ) upgrade ( J.Andreina via vinayakumarb )
HDFS-7879. hdfs.dll does not export functions of the public libhdfs API.
(Chris Nauroth via wheat9)
BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
HDFS-7720. Quota by Storage Type API, tools and ClientNameNode HDFS-7720. Quota by Storage Type API, tools and ClientNameNode

View File

@ -27,7 +27,15 @@ include(../../../hadoop-common-project/hadoop-common/src/JNIFlags.cmake NO_POLIC
function(add_dual_library LIBNAME) function(add_dual_library LIBNAME)
add_library(${LIBNAME} SHARED ${ARGN}) add_library(${LIBNAME} SHARED ${ARGN})
add_library(${LIBNAME}_static STATIC ${ARGN}) add_library(${LIBNAME}_static STATIC ${ARGN})
set_target_properties(${LIBNAME}_static PROPERTIES OUTPUT_NAME ${LIBNAME}) # Linux builds traditionally ship a libhdfs.a (static linking) and libhdfs.so
# (dynamic linking). On Windows, we cannot use the same base name for both
# static and dynamic, because Windows does not use distinct file extensions
# for a statically linked library vs. a DLL import library. Both use the
# .lib extension. On Windows, we'll build the static library as
# hdfs_static.lib.
if (NOT WIN32)
set_target_properties(${LIBNAME}_static PROPERTIES OUTPUT_NAME ${LIBNAME})
endif (NOT WIN32)
endfunction(add_dual_library) endfunction(add_dual_library)
# Link both a static and a dynamic target against some libraries # Link both a static and a dynamic target against some libraries
@ -105,11 +113,14 @@ else (WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_GNU_SOURCE") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_GNU_SOURCE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
set(OS_DIR main/native/libhdfs/os/posix) set(OS_DIR main/native/libhdfs/os/posix)
set(OS_LINK_LIBRARIES pthread) set(OS_LINK_LIBRARIES pthread)
set(OUT_DIR target/usr/local/lib) set(OUT_DIR target/usr/local/lib)
endif (WIN32) endif (WIN32)
add_definitions(-DLIBHDFS_DLL_EXPORT)
include_directories( include_directories(
${GENERATED_JAVAH} ${GENERATED_JAVAH}
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
@ -150,7 +161,7 @@ add_executable(test_libhdfs_ops
main/native/libhdfs/test/test_libhdfs_ops.c main/native/libhdfs/test/test_libhdfs_ops.c
) )
target_link_libraries(test_libhdfs_ops target_link_libraries(test_libhdfs_ops
hdfs hdfs_static
${JAVA_JVM_LIBRARY} ${JAVA_JVM_LIBRARY}
) )
@ -158,7 +169,7 @@ add_executable(test_libhdfs_read
main/native/libhdfs/test/test_libhdfs_read.c main/native/libhdfs/test/test_libhdfs_read.c
) )
target_link_libraries(test_libhdfs_read target_link_libraries(test_libhdfs_read
hdfs hdfs_static
${JAVA_JVM_LIBRARY} ${JAVA_JVM_LIBRARY}
) )
@ -166,7 +177,7 @@ add_executable(test_libhdfs_write
main/native/libhdfs/test/test_libhdfs_write.c main/native/libhdfs/test/test_libhdfs_write.c
) )
target_link_libraries(test_libhdfs_write target_link_libraries(test_libhdfs_write
hdfs hdfs_static
${JAVA_JVM_LIBRARY} ${JAVA_JVM_LIBRARY}
) )
@ -196,7 +207,7 @@ add_executable(test_libhdfs_threaded
${OS_DIR}/thread.c ${OS_DIR}/thread.c
) )
target_link_libraries(test_libhdfs_threaded target_link_libraries(test_libhdfs_threaded
hdfs hdfs_static
native_mini_dfs native_mini_dfs
${OS_LINK_LIBRARIES} ${OS_LINK_LIBRARIES}
) )
@ -206,7 +217,7 @@ add_executable(test_libhdfs_zerocopy
main/native/libhdfs/test/test_libhdfs_zerocopy.c main/native/libhdfs/test/test_libhdfs_zerocopy.c
) )
target_link_libraries(test_libhdfs_zerocopy target_link_libraries(test_libhdfs_zerocopy
hdfs hdfs_static
native_mini_dfs native_mini_dfs
${OS_LINK_LIBRARIES} ${OS_LINK_LIBRARIES}
) )

View File

@ -24,6 +24,30 @@
#include <stdint.h> /* for uint64_t, etc. */ #include <stdint.h> /* for uint64_t, etc. */
#include <time.h> /* for time_t */ #include <time.h> /* for time_t */
/*
* Support export of DLL symbols during libhdfs build, and import of DLL symbols
* during client application build. A client application may optionally define
* symbol LIBHDFS_DLL_IMPORT in its build. This is not strictly required, but
* the compiler can produce more efficient code with it.
*/
#ifdef WIN32
#ifdef LIBHDFS_DLL_EXPORT
#define LIBHDFS_EXTERNAL __declspec(dllexport)
#elif LIBHDFS_DLL_IMPORT
#define LIBHDFS_EXTERNAL __declspec(dllimport)
#else
#define LIBHDFS_EXTERNAL
#endif
#else
#ifdef LIBHDFS_DLL_EXPORT
#define LIBHDFS_EXTERNAL __attribute__((visibility("default")))
#elif LIBHDFS_DLL_IMPORT
#define LIBHDFS_EXTERNAL __attribute__((visibility("default")))
#else
#define LIBHDFS_EXTERNAL
#endif
#endif
#ifndef O_RDONLY #ifndef O_RDONLY
#define O_RDONLY 1 #define O_RDONLY 1
#endif #endif
@ -77,6 +101,7 @@ extern "C" {
* @param file The HDFS file * @param file The HDFS file
* @return 1 if the file is open for read; 0 otherwise * @return 1 if the file is open for read; 0 otherwise
*/ */
LIBHDFS_EXTERNAL
int hdfsFileIsOpenForRead(hdfsFile file); int hdfsFileIsOpenForRead(hdfsFile file);
/** /**
@ -85,6 +110,7 @@ extern "C" {
* @param file The HDFS file * @param file The HDFS file
* @return 1 if the file is open for write; 0 otherwise * @return 1 if the file is open for write; 0 otherwise
*/ */
LIBHDFS_EXTERNAL
int hdfsFileIsOpenForWrite(hdfsFile file); int hdfsFileIsOpenForWrite(hdfsFile file);
struct hdfsReadStatistics { struct hdfsReadStatistics {
@ -107,6 +133,7 @@ extern "C" {
* ENOTSUP. webhdfs, LocalFilesystem, and so forth may * ENOTSUP. webhdfs, LocalFilesystem, and so forth may
* not support read statistics. * not support read statistics.
*/ */
LIBHDFS_EXTERNAL
int hdfsFileGetReadStatistics(hdfsFile file, int hdfsFileGetReadStatistics(hdfsFile file,
struct hdfsReadStatistics **stats); struct hdfsReadStatistics **stats);
@ -115,6 +142,7 @@ extern "C" {
* *
* @return the number of remote bytes read. * @return the number of remote bytes read.
*/ */
LIBHDFS_EXTERNAL
int64_t hdfsReadStatisticsGetRemoteBytesRead( int64_t hdfsReadStatisticsGetRemoteBytesRead(
const struct hdfsReadStatistics *stats); const struct hdfsReadStatistics *stats);
@ -129,6 +157,7 @@ extern "C" {
* statistics. * statistics.
* Errno will also be set to this code on failure. * Errno will also be set to this code on failure.
*/ */
LIBHDFS_EXTERNAL
int hdfsFileClearReadStatistics(hdfsFile file); int hdfsFileClearReadStatistics(hdfsFile file);
/** /**
@ -136,6 +165,7 @@ extern "C" {
* *
* @param stats The HDFS read statistics to free. * @param stats The HDFS read statistics to free.
*/ */
LIBHDFS_EXTERNAL
void hdfsFileFreeReadStatistics(struct hdfsReadStatistics *stats); void hdfsFileFreeReadStatistics(struct hdfsReadStatistics *stats);
/** /**
@ -147,6 +177,7 @@ extern "C" {
* @return Returns a handle to the filesystem or NULL on error. * @return Returns a handle to the filesystem or NULL on error.
* @deprecated Use hdfsBuilderConnect instead. * @deprecated Use hdfsBuilderConnect instead.
*/ */
LIBHDFS_EXTERNAL
hdfsFS hdfsConnectAsUser(const char* nn, tPort port, const char *user); hdfsFS hdfsConnectAsUser(const char* nn, tPort port, const char *user);
/** /**
@ -157,6 +188,7 @@ extern "C" {
* @return Returns a handle to the filesystem or NULL on error. * @return Returns a handle to the filesystem or NULL on error.
* @deprecated Use hdfsBuilderConnect instead. * @deprecated Use hdfsBuilderConnect instead.
*/ */
LIBHDFS_EXTERNAL
hdfsFS hdfsConnect(const char* nn, tPort port); hdfsFS hdfsConnect(const char* nn, tPort port);
/** /**
@ -170,6 +202,7 @@ extern "C" {
* @return Returns a handle to the filesystem or NULL on error. * @return Returns a handle to the filesystem or NULL on error.
* @deprecated Use hdfsBuilderConnect instead. * @deprecated Use hdfsBuilderConnect instead.
*/ */
LIBHDFS_EXTERNAL
hdfsFS hdfsConnectAsUserNewInstance(const char* nn, tPort port, const char *user ); hdfsFS hdfsConnectAsUserNewInstance(const char* nn, tPort port, const char *user );
/** /**
@ -182,6 +215,7 @@ extern "C" {
* @return Returns a handle to the filesystem or NULL on error. * @return Returns a handle to the filesystem or NULL on error.
* @deprecated Use hdfsBuilderConnect instead. * @deprecated Use hdfsBuilderConnect instead.
*/ */
LIBHDFS_EXTERNAL
hdfsFS hdfsConnectNewInstance(const char* nn, tPort port); hdfsFS hdfsConnectNewInstance(const char* nn, tPort port);
/** /**
@ -196,6 +230,7 @@ extern "C" {
* @param bld The HDFS builder * @param bld The HDFS builder
* @return Returns a handle to the filesystem, or NULL on error. * @return Returns a handle to the filesystem, or NULL on error.
*/ */
LIBHDFS_EXTERNAL
hdfsFS hdfsBuilderConnect(struct hdfsBuilder *bld); hdfsFS hdfsBuilderConnect(struct hdfsBuilder *bld);
/** /**
@ -203,6 +238,7 @@ extern "C" {
* *
* @return The HDFS builder, or NULL on error. * @return The HDFS builder, or NULL on error.
*/ */
LIBHDFS_EXTERNAL
struct hdfsBuilder *hdfsNewBuilder(void); struct hdfsBuilder *hdfsNewBuilder(void);
/** /**
@ -211,6 +247,7 @@ extern "C" {
* *
* @param bld The HDFS builder * @param bld The HDFS builder
*/ */
LIBHDFS_EXTERNAL
void hdfsBuilderSetForceNewInstance(struct hdfsBuilder *bld); void hdfsBuilderSetForceNewInstance(struct hdfsBuilder *bld);
/** /**
@ -234,6 +271,7 @@ extern "C" {
* hdfsBuilderSetNameNodePort. However, you must not pass the * hdfsBuilderSetNameNodePort. However, you must not pass the
* port in two different ways. * port in two different ways.
*/ */
LIBHDFS_EXTERNAL
void hdfsBuilderSetNameNode(struct hdfsBuilder *bld, const char *nn); void hdfsBuilderSetNameNode(struct hdfsBuilder *bld, const char *nn);
/** /**
@ -242,6 +280,7 @@ extern "C" {
* @param bld The HDFS builder * @param bld The HDFS builder
* @param port The port. * @param port The port.
*/ */
LIBHDFS_EXTERNAL
void hdfsBuilderSetNameNodePort(struct hdfsBuilder *bld, tPort port); void hdfsBuilderSetNameNodePort(struct hdfsBuilder *bld, tPort port);
/** /**
@ -250,6 +289,7 @@ extern "C" {
* @param bld The HDFS builder * @param bld The HDFS builder
* @param userName The user name. The string will be shallow-copied. * @param userName The user name. The string will be shallow-copied.
*/ */
LIBHDFS_EXTERNAL
void hdfsBuilderSetUserName(struct hdfsBuilder *bld, const char *userName); void hdfsBuilderSetUserName(struct hdfsBuilder *bld, const char *userName);
/** /**
@ -260,6 +300,7 @@ extern "C" {
* @param kerbTicketCachePath The Kerberos ticket cache path. The string * @param kerbTicketCachePath The Kerberos ticket cache path. The string
* will be shallow-copied. * will be shallow-copied.
*/ */
LIBHDFS_EXTERNAL
void hdfsBuilderSetKerbTicketCachePath(struct hdfsBuilder *bld, void hdfsBuilderSetKerbTicketCachePath(struct hdfsBuilder *bld,
const char *kerbTicketCachePath); const char *kerbTicketCachePath);
@ -271,6 +312,7 @@ extern "C" {
* *
* @param bld The HDFS builder * @param bld The HDFS builder
*/ */
LIBHDFS_EXTERNAL
void hdfsFreeBuilder(struct hdfsBuilder *bld); void hdfsFreeBuilder(struct hdfsBuilder *bld);
/** /**
@ -284,6 +326,7 @@ extern "C" {
* *
* @return 0 on success; nonzero error code otherwise. * @return 0 on success; nonzero error code otherwise.
*/ */
LIBHDFS_EXTERNAL
int hdfsBuilderConfSetStr(struct hdfsBuilder *bld, const char *key, int hdfsBuilderConfSetStr(struct hdfsBuilder *bld, const char *key,
const char *val); const char *val);
@ -298,6 +341,7 @@ extern "C" {
* @return 0 on success; nonzero error code otherwise. * @return 0 on success; nonzero error code otherwise.
* Failure to find the key is not an error. * Failure to find the key is not an error.
*/ */
LIBHDFS_EXTERNAL
int hdfsConfGetStr(const char *key, char **val); int hdfsConfGetStr(const char *key, char **val);
/** /**
@ -310,6 +354,7 @@ extern "C" {
* @return 0 on success; nonzero error code otherwise. * @return 0 on success; nonzero error code otherwise.
* Failure to find the key is not an error. * Failure to find the key is not an error.
*/ */
LIBHDFS_EXTERNAL
int hdfsConfGetInt(const char *key, int32_t *val); int hdfsConfGetInt(const char *key, int32_t *val);
/** /**
@ -317,6 +362,7 @@ extern "C" {
* *
* @param val A configuration string obtained from hdfsConfGetStr * @param val A configuration string obtained from hdfsConfGetStr
*/ */
LIBHDFS_EXTERNAL
void hdfsConfStrFree(char *val); void hdfsConfStrFree(char *val);
/** /**
@ -327,6 +373,7 @@ extern "C" {
* Even if there is an error, the resources associated with the * Even if there is an error, the resources associated with the
* hdfsFS will be freed. * hdfsFS will be freed.
*/ */
LIBHDFS_EXTERNAL
int hdfsDisconnect(hdfsFS fs); int hdfsDisconnect(hdfsFS fs);
@ -344,6 +391,7 @@ extern "C" {
* default configured values. * default configured values.
* @return Returns the handle to the open file or NULL on error. * @return Returns the handle to the open file or NULL on error.
*/ */
LIBHDFS_EXTERNAL
hdfsFile hdfsOpenFile(hdfsFS fs, const char* path, int flags, hdfsFile hdfsOpenFile(hdfsFS fs, const char* path, int flags,
int bufferSize, short replication, tSize blocksize); int bufferSize, short replication, tSize blocksize);
@ -355,6 +403,7 @@ extern "C" {
* ENOTSUP if the file does not support unbuffering * ENOTSUP if the file does not support unbuffering
* Errno will also be set to this value. * Errno will also be set to this value.
*/ */
LIBHDFS_EXTERNAL
int hdfsUnbufferFile(hdfsFile file); int hdfsUnbufferFile(hdfsFile file);
/** /**
@ -367,6 +416,7 @@ extern "C" {
* be freed at the end of this call, even if there was an I/O * be freed at the end of this call, even if there was an I/O
* error. * error.
*/ */
LIBHDFS_EXTERNAL
int hdfsCloseFile(hdfsFS fs, hdfsFile file); int hdfsCloseFile(hdfsFS fs, hdfsFile file);
@ -376,6 +426,7 @@ extern "C" {
* @param path The path to look for * @param path The path to look for
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsExists(hdfsFS fs, const char *path); int hdfsExists(hdfsFS fs, const char *path);
@ -387,6 +438,7 @@ extern "C" {
* @param desiredPos Offset into the file to seek into. * @param desiredPos Offset into the file to seek into.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos); int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos);
@ -396,6 +448,7 @@ extern "C" {
* @param file The file handle. * @param file The file handle.
* @return Current offset, -1 on error. * @return Current offset, -1 on error.
*/ */
LIBHDFS_EXTERNAL
tOffset hdfsTell(hdfsFS fs, hdfsFile file); tOffset hdfsTell(hdfsFS fs, hdfsFile file);
@ -413,6 +466,7 @@ extern "C" {
* and set errno to EINTR if data is temporarily unavailable, * and set errno to EINTR if data is temporarily unavailable,
* but we are not yet at the end of the file. * but we are not yet at the end of the file.
*/ */
LIBHDFS_EXTERNAL
tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length); tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length);
/** /**
@ -424,6 +478,7 @@ extern "C" {
* @param length The length of the buffer. * @param length The length of the buffer.
* @return See hdfsRead * @return See hdfsRead
*/ */
LIBHDFS_EXTERNAL
tSize hdfsPread(hdfsFS fs, hdfsFile file, tOffset position, tSize hdfsPread(hdfsFS fs, hdfsFile file, tOffset position,
void* buffer, tSize length); void* buffer, tSize length);
@ -436,6 +491,7 @@ extern "C" {
* @param length The no. of bytes to write. * @param length The no. of bytes to write.
* @return Returns the number of bytes written, -1 on error. * @return Returns the number of bytes written, -1 on error.
*/ */
LIBHDFS_EXTERNAL
tSize hdfsWrite(hdfsFS fs, hdfsFile file, const void* buffer, tSize hdfsWrite(hdfsFS fs, hdfsFile file, const void* buffer,
tSize length); tSize length);
@ -446,6 +502,7 @@ extern "C" {
* @param file The file handle. * @param file The file handle.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsFlush(hdfsFS fs, hdfsFile file); int hdfsFlush(hdfsFS fs, hdfsFile file);
@ -456,6 +513,7 @@ extern "C" {
* @param file file handle * @param file file handle
* @return 0 on success, -1 on error and sets errno * @return 0 on success, -1 on error and sets errno
*/ */
LIBHDFS_EXTERNAL
int hdfsHFlush(hdfsFS fs, hdfsFile file); int hdfsHFlush(hdfsFS fs, hdfsFile file);
@ -467,6 +525,7 @@ extern "C" {
* @param file file handle * @param file file handle
* @return 0 on success, -1 on error and sets errno * @return 0 on success, -1 on error and sets errno
*/ */
LIBHDFS_EXTERNAL
int hdfsHSync(hdfsFS fs, hdfsFile file); int hdfsHSync(hdfsFS fs, hdfsFile file);
@ -477,6 +536,7 @@ extern "C" {
* @param file The file handle. * @param file The file handle.
* @return Returns available bytes; -1 on error. * @return Returns available bytes; -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsAvailable(hdfsFS fs, hdfsFile file); int hdfsAvailable(hdfsFS fs, hdfsFile file);
@ -488,6 +548,7 @@ extern "C" {
* @param dst The path of destination file. * @param dst The path of destination file.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsCopy(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst); int hdfsCopy(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);
@ -499,6 +560,7 @@ extern "C" {
* @param dst The path of destination file. * @param dst The path of destination file.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsMove(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst); int hdfsMove(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);
@ -511,6 +573,7 @@ extern "C" {
* case of a file the recursive argument is irrelevant. * case of a file the recursive argument is irrelevant.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsDelete(hdfsFS fs, const char* path, int recursive); int hdfsDelete(hdfsFS fs, const char* path, int recursive);
/** /**
@ -520,6 +583,7 @@ extern "C" {
* @param newPath The path of the destination file. * @param newPath The path of the destination file.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsRename(hdfsFS fs, const char* oldPath, const char* newPath); int hdfsRename(hdfsFS fs, const char* oldPath, const char* newPath);
@ -531,6 +595,7 @@ extern "C" {
* @param bufferSize The length of user-buffer. * @param bufferSize The length of user-buffer.
* @return Returns buffer, NULL on error. * @return Returns buffer, NULL on error.
*/ */
LIBHDFS_EXTERNAL
char* hdfsGetWorkingDirectory(hdfsFS fs, char *buffer, size_t bufferSize); char* hdfsGetWorkingDirectory(hdfsFS fs, char *buffer, size_t bufferSize);
@ -541,6 +606,7 @@ extern "C" {
* @param path The path of the new 'cwd'. * @param path The path of the new 'cwd'.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsSetWorkingDirectory(hdfsFS fs, const char* path); int hdfsSetWorkingDirectory(hdfsFS fs, const char* path);
@ -551,6 +617,7 @@ extern "C" {
* @param path The path of the directory. * @param path The path of the directory.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsCreateDirectory(hdfsFS fs, const char* path); int hdfsCreateDirectory(hdfsFS fs, const char* path);
@ -561,6 +628,7 @@ extern "C" {
* @param path The path of the file. * @param path The path of the file.
* @return Returns 0 on success, -1 on error. * @return Returns 0 on success, -1 on error.
*/ */
LIBHDFS_EXTERNAL
int hdfsSetReplication(hdfsFS fs, const char* path, int16_t replication); int hdfsSetReplication(hdfsFS fs, const char* path, int16_t replication);
@ -590,6 +658,7 @@ extern "C" {
* @return Returns a dynamically-allocated array of hdfsFileInfo * @return Returns a dynamically-allocated array of hdfsFileInfo
* objects; NULL on error. * objects; NULL on error.
*/ */
LIBHDFS_EXTERNAL
hdfsFileInfo *hdfsListDirectory(hdfsFS fs, const char* path, hdfsFileInfo *hdfsListDirectory(hdfsFS fs, const char* path,
int *numEntries); int *numEntries);
@ -603,6 +672,7 @@ extern "C" {
* @return Returns a dynamically-allocated hdfsFileInfo object; * @return Returns a dynamically-allocated hdfsFileInfo object;
* NULL on error. * NULL on error.
*/ */
LIBHDFS_EXTERNAL
hdfsFileInfo *hdfsGetPathInfo(hdfsFS fs, const char* path); hdfsFileInfo *hdfsGetPathInfo(hdfsFS fs, const char* path);
@ -612,6 +682,7 @@ extern "C" {
* objects. * objects.
* @param numEntries The size of the array. * @param numEntries The size of the array.
*/ */
LIBHDFS_EXTERNAL
void hdfsFreeFileInfo(hdfsFileInfo *hdfsFileInfo, int numEntries); void hdfsFreeFileInfo(hdfsFileInfo *hdfsFileInfo, int numEntries);
/** /**
@ -620,6 +691,7 @@ extern "C" {
* @return -1 if there was an error (errno will be set), 0 if the file is * @return -1 if there was an error (errno will be set), 0 if the file is
* not encrypted, 1 if the file is encrypted. * not encrypted, 1 if the file is encrypted.
*/ */
LIBHDFS_EXTERNAL
int hdfsFileIsEncrypted(hdfsFileInfo *hdfsFileInfo); int hdfsFileIsEncrypted(hdfsFileInfo *hdfsFileInfo);
@ -635,6 +707,7 @@ extern "C" {
* @return Returns a dynamically-allocated 2-d array of blocks-hosts; * @return Returns a dynamically-allocated 2-d array of blocks-hosts;
* NULL on error. * NULL on error.
*/ */
LIBHDFS_EXTERNAL
char*** hdfsGetHosts(hdfsFS fs, const char* path, char*** hdfsGetHosts(hdfsFS fs, const char* path,
tOffset start, tOffset length); tOffset start, tOffset length);
@ -645,6 +718,7 @@ extern "C" {
* objects. * objects.
* @param numEntries The size of the array. * @param numEntries The size of the array.
*/ */
LIBHDFS_EXTERNAL
void hdfsFreeHosts(char ***blockHosts); void hdfsFreeHosts(char ***blockHosts);
@ -656,6 +730,7 @@ extern "C" {
* *
* @return Returns the default blocksize, or -1 on error. * @return Returns the default blocksize, or -1 on error.
*/ */
LIBHDFS_EXTERNAL
tOffset hdfsGetDefaultBlockSize(hdfsFS fs); tOffset hdfsGetDefaultBlockSize(hdfsFS fs);
@ -669,6 +744,7 @@ extern "C" {
* *
* @return Returns the default blocksize, or -1 on error. * @return Returns the default blocksize, or -1 on error.
*/ */
LIBHDFS_EXTERNAL
tOffset hdfsGetDefaultBlockSizeAtPath(hdfsFS fs, const char *path); tOffset hdfsGetDefaultBlockSizeAtPath(hdfsFS fs, const char *path);
@ -677,6 +753,7 @@ extern "C" {
* @param fs The configured filesystem handle. * @param fs The configured filesystem handle.
* @return Returns the raw-capacity; -1 on error. * @return Returns the raw-capacity; -1 on error.
*/ */
LIBHDFS_EXTERNAL
tOffset hdfsGetCapacity(hdfsFS fs); tOffset hdfsGetCapacity(hdfsFS fs);
@ -685,6 +762,7 @@ extern "C" {
* @param fs The configured filesystem handle. * @param fs The configured filesystem handle.
* @return Returns the total-size; -1 on error. * @return Returns the total-size; -1 on error.
*/ */
LIBHDFS_EXTERNAL
tOffset hdfsGetUsed(hdfsFS fs); tOffset hdfsGetUsed(hdfsFS fs);
/** /**
@ -696,6 +774,7 @@ extern "C" {
* @param group Group string. Set to NULL for 'no change' * @param group Group string. Set to NULL for 'no change'
* @return 0 on success else -1 * @return 0 on success else -1
*/ */
LIBHDFS_EXTERNAL
int hdfsChown(hdfsFS fs, const char* path, const char *owner, int hdfsChown(hdfsFS fs, const char* path, const char *owner,
const char *group); const char *group);
@ -706,7 +785,8 @@ extern "C" {
* @param mode the bitmask to set it to * @param mode the bitmask to set it to
* @return 0 on success else -1 * @return 0 on success else -1
*/ */
int hdfsChmod(hdfsFS fs, const char* path, short mode); LIBHDFS_EXTERNAL
int hdfsChmod(hdfsFS fs, const char* path, short mode);
/** /**
* hdfsUtime * hdfsUtime
@ -716,6 +796,7 @@ extern "C" {
* @param atime new access time or -1 for no change * @param atime new access time or -1 for no change
* @return 0 on success else -1 * @return 0 on success else -1
*/ */
LIBHDFS_EXTERNAL
int hdfsUtime(hdfsFS fs, const char* path, tTime mtime, tTime atime); int hdfsUtime(hdfsFS fs, const char* path, tTime mtime, tTime atime);
/** /**
@ -728,6 +809,7 @@ extern "C" {
* not be allocated. If NULL is returned, errno will * not be allocated. If NULL is returned, errno will
* contain the error number. * contain the error number.
*/ */
LIBHDFS_EXTERNAL
struct hadoopRzOptions *hadoopRzOptionsAlloc(void); struct hadoopRzOptions *hadoopRzOptionsAlloc(void);
/** /**
@ -739,6 +821,7 @@ extern "C" {
* *
* @return 0 on success; -1 plus errno on failure. * @return 0 on success; -1 plus errno on failure.
*/ */
LIBHDFS_EXTERNAL
int hadoopRzOptionsSetSkipChecksum( int hadoopRzOptionsSetSkipChecksum(
struct hadoopRzOptions *opts, int skip); struct hadoopRzOptions *opts, int skip);
@ -756,6 +839,7 @@ extern "C" {
* instantiated; * instantiated;
* -1 plus errno otherwise. * -1 plus errno otherwise.
*/ */
LIBHDFS_EXTERNAL
int hadoopRzOptionsSetByteBufferPool( int hadoopRzOptionsSetByteBufferPool(
struct hadoopRzOptions *opts, const char *className); struct hadoopRzOptions *opts, const char *className);
@ -765,6 +849,7 @@ extern "C" {
* @param opts The options structure to free. * @param opts The options structure to free.
* Any associated ByteBufferPool will also be freed. * Any associated ByteBufferPool will also be freed.
*/ */
LIBHDFS_EXTERNAL
void hadoopRzOptionsFree(struct hadoopRzOptions *opts); void hadoopRzOptionsFree(struct hadoopRzOptions *opts);
/** /**
@ -790,6 +875,7 @@ extern "C" {
* zero-copy read, and there was no ByteBufferPool * zero-copy read, and there was no ByteBufferPool
* supplied. * supplied.
*/ */
LIBHDFS_EXTERNAL
struct hadoopRzBuffer* hadoopReadZero(hdfsFile file, struct hadoopRzBuffer* hadoopReadZero(hdfsFile file,
struct hadoopRzOptions *opts, int32_t maxLength); struct hadoopRzOptions *opts, int32_t maxLength);
@ -799,6 +885,7 @@ extern "C" {
* @param buffer a buffer returned from readZero. * @param buffer a buffer returned from readZero.
* @return the length of the buffer. * @return the length of the buffer.
*/ */
LIBHDFS_EXTERNAL
int32_t hadoopRzBufferLength(const struct hadoopRzBuffer *buffer); int32_t hadoopRzBufferLength(const struct hadoopRzBuffer *buffer);
/** /**
@ -811,6 +898,7 @@ extern "C" {
* @return a pointer to the start of the buffer. This will be * @return a pointer to the start of the buffer. This will be
* NULL when end-of-file has been reached. * NULL when end-of-file has been reached.
*/ */
LIBHDFS_EXTERNAL
const void *hadoopRzBufferGet(const struct hadoopRzBuffer *buffer); const void *hadoopRzBufferGet(const struct hadoopRzBuffer *buffer);
/** /**
@ -820,12 +908,14 @@ extern "C" {
* the same stream you called hadoopReadZero on. * the same stream you called hadoopReadZero on.
* @param buffer The buffer to release. * @param buffer The buffer to release.
*/ */
LIBHDFS_EXTERNAL
void hadoopRzBufferFree(hdfsFile file, struct hadoopRzBuffer *buffer); void hadoopRzBufferFree(hdfsFile file, struct hadoopRzBuffer *buffer);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#undef LIBHDFS_EXTERNAL
#endif /*LIBHDFS_HDFS_H*/ #endif /*LIBHDFS_HDFS_H*/
/** /**