cctools
hdfs_library.h
1/*
2Copyright (C) 2022 The University of Notre Dame
3This software is distributed under the GNU General Public License.
4See the file COPYING for details.
5*/
6
7#ifndef HDFS_LIBRARY_H
8#define HDFS_LIBRARY_H
9
10#include <stdio.h>
11#include <stdlib.h>
12#include <time.h>
13
14#include "int_sizes.h"
15
16#ifndef HDFS_EINTERNAL
17#define HDFS_EINTERNAL 255
18#endif
19
20typedef INT32_T tSize;
21typedef time_t tTime;
22typedef INT64_T tOffset;
23typedef UINT16_T tPort;
24
25typedef enum tObjectKind {
26 kObjectKindFile = 'F',
27 kObjectKindDirectory = 'D'
28} tObjectKind;
29
30typedef void *hdfsFS;
31typedef void *hdfsFile;
32
33typedef struct {
34 tObjectKind mKind;
35 char *mName;
36 tTime mLastMod;
37 tOffset mSize;
38 short mReplication;
39 tOffset mBlockSize;
40 char *mOwner;
41 char *mGroup;
42 short mPermissions;
43 tTime mLastAccess;
45
47 void *libjvm_handle;
48 void *libhdfs_handle;
49 hdfsFS (*connect) (const char *, tPort);
50 hdfsFS (*connect_as_user) (const char *, tPort, const char *, const char *[], int);
51 int (*disconnect) (hdfsFS);
52 hdfsFileInfo *(*listdir) (hdfsFS, const char *, int *);
53 hdfsFile (*open) (hdfsFS, const char *, int, int, short, tSize);
54 int (*close) (hdfsFS, hdfsFile);
55 int (*flush) (hdfsFS, hdfsFile);
56 tSize (*read) (hdfsFS, hdfsFile, void *, tSize);
57 tSize (*pread) (hdfsFS, hdfsFile, tOffset, void *, tSize);
58 tSize (*write) (hdfsFS, hdfsFile, const void *, tSize);
59 int (*exists) (hdfsFS, const char *);
60 int (*mkdir) (hdfsFS, const char *);
61 int (*unlink) (hdfsFS, const char *, int recursive);
62 int (*rename) (hdfsFS, const char *, const char *);
63 hdfsFileInfo *(*stat) (hdfsFS, const char *);
64 void (*free_stat) (hdfsFileInfo *, int);
65 char ***(*get_hosts) (hdfsFS, const char *, tOffset, tOffset);
66 void (*free_hosts) (char ***);
67 tOffset (*get_default_block_size) (hdfsFS);
68 tOffset (*get_capacity) (hdfsFS);
69 tOffset (*get_used) (hdfsFS);
70 int (*chmod) (hdfsFS, const char *, short);
71 int (*utime) (hdfsFS, const char *, tTime, tTime);
72 int (*chdir) (hdfsFS, const char *);
73 tOffset (*tell) (hdfsFS, hdfsFile);
74 int (*setrep) (hdfsFS fs, const char *path, UINT16_T nreps );
75 int (*copy) (hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);
76};
77
78int hdfs_library_envinit(void);
79struct hdfs_library *hdfs_library_open(void);
80void hdfs_library_close(struct hdfs_library *hs);
81
82#endif
Definition hdfs_library.h:33
Definition hdfs_library.h:46