File: hdfs.h

package info (click to toggle)
snap-aligner 2.0.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,652 kB
  • sloc: cpp: 41,051; ansic: 5,239; python: 227; makefile: 85; sh: 28
file content (768 lines) | stat: -rwxr-xr-x 27,882 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef LIBHDFS_HDFS_H
#define LIBHDFS_HDFS_H

#include <fcntl.h>    /* for O_RDONLY, O_WRONLY */
#include <time.h>     /* for time_t */

#ifdef WIN32

#      ifdef WIN32_EXP
#        define WIN32EXP extern __declspec(dllexport)
#      else
#        define WIN32EXP extern __declspec(dllimport)
#      endif

#ifndef O_ACCMODE
#   define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
#endif

#if _MSC_VER >= 1600
#include <stdint.h>
#else

#if (_MSC_VER < 1300)
   typedef signed char       int8_t;
   typedef signed short      int16_t;
   typedef signed int        int32_t;
   typedef unsigned char     uint8_t;
   typedef unsigned short    uint16_t;
   typedef unsigned int      uint32_t;
#else
   typedef signed __int8     int8_t;
   typedef signed __int16    int16_t;
   typedef signed __int32    int32_t;
   typedef unsigned __int8   uint8_t;
   typedef unsigned __int16  uint16_t;
   typedef unsigned __int32  uint32_t;
#endif

typedef signed __int64       int64_t;
typedef unsigned __int64     uint64_t;

#endif

#else
#define WIN32EXP
#include <stdint.h>
#endif

#ifndef WIN32
    typedef int32_t   tSize;      /*  size of data for read/write io ops */
    typedef int64_t   tOffset;    /*  offset within the file             */
    typedef uint16_t  tPort;      /*  port                               */
#else
    typedef int             tSize;    /*  size of data for read/write io ops */
    typedef long long       tOffset;  /*  offset within the file             */
    typedef unsigned short  tPort;    /*  port                               */
#endif

#ifndef PRId64
#define PRId64 "I64d"
#endif

#ifndef O_RDONLY
#define O_RDONLY 1
#endif

#ifndef O_WRONLY
#define O_WRONLY 2
#endif

#ifndef EINTERNAL
#define EINTERNAL 255
#endif

#undef WIN32EXP
#define WIN32EXP

/** All APIs set errno to meaningful values */

#ifdef __cplusplus
extern  "C" {
#endif

	// jelson
	void staticLibInit();

    /**
     * Some utility decls used in libhdfs.
     */
    struct hdfsBuilder;

    typedef time_t    tTime; /*  time type in seconds */

    typedef enum tObjectKind {
        kObjectKindFile = 'F',
        kObjectKindDirectory = 'D',
    } tObjectKind;

    /**
     * The C reflection of org.apache.org.hadoop.FileSystem .
     */
    struct hdfs_internal;
    typedef struct hdfs_internal* hdfsFS;

    struct hdfsFile_internal;
    typedef struct hdfsFile_internal* hdfsFile;

    WIN32EXP int hdfsLibInit ( void * );
    
    /**
     * Disable the direct read optimization for a file.
     *
     * This is mainly provided for unit testing purposes.
     *
     * @param file     The HDFS file
     */    
    WIN32EXP void hdfsFileDisableDirectRead(hdfsFile file);
    
    /**
     * Determine if a file is using the "direct read" optimization.
     *
     * @param file     The HDFS file
     * @return         1 if the file is using the direct read optimization,
     *                 0 otherwise.
     */
    WIN32EXP int hdfsFileUsesDirectRead(hdfsFile file);
    
    /**
     * Determine if a file is open for read.
     *
     * @param file     The HDFS file
     * @return         1 if the file is open for read; 0 otherwise
     */
    WIN32EXP int hdfsFileIsOpenForRead(hdfsFile file);

    /**
     * Determine if a file is open for write.
     *
     * @param file     The HDFS file
     * @return         1 if the file is open for write; 0 otherwise
     */
    WIN32EXP int hdfsFileIsOpenForWrite(hdfsFile file);

    struct hdfsReadStatistics {
        uint64_t totalBytesRead;
        uint64_t totalLocalBytesRead;
        uint64_t totalShortCircuitBytesRead;
    };

    /**
     * Get read statistics about a file.  This is only applicable to files
     * opened for reading.
     *
     * @param file     The HDFS file
     * @param stats    (out parameter) on a successful return, the read
     *                 statistics.  Unchanged otherwise.  You must free the
     *                 returned statistics with hdfsFileFreeReadStatistics.
     * @return         0 if the statistics were successfully returned,
     *                 -1 otherwise.  On a failure, please check errno against
     *                 ENOTSUP.  webhdfs, LocalFilesystem, and so forth may
     *                 not support read statistics.
     */
    WIN32EXP int hdfsFileGetReadStatistics(hdfsFile file,
                                  struct hdfsReadStatistics **stats);

    /**
     * @param stats    HDFS read statistics for a file.
     *
     * @return the number of remote bytes read.
     */
    WIN32EXP int64_t hdfsReadStatisticsGetRemoteBytesRead(
                            const struct hdfsReadStatistics *stats);

    /**
     * Free some HDFS read statistics.
     *
     * @param stats    The HDFS read statistics to free.
     */
    WIN32EXP void hdfsFileFreeReadStatistics(struct hdfsReadStatistics *stats);

    /**
     * hdfsConnectAsUser - Connect to a hdfs file system as a specific user
     * Connect to the hdfs.
     * @param nn   The NameNode.  See hdfsBuilderSetNameNode for details.
     * @param port The port on which the server is listening.
     * @param user the user name (this is hadoop domain user). Or NULL is equivelant to hhdfsConnect(host, port)
     * @return Returns a handle to the filesystem or NULL on error.
     * @deprecated Use hdfsBuilderConnect instead.
     */
    WIN32EXP hdfsFS hdfsConnectAsUser(const char* nn, tPort port, const char *user);

    /**
     * hdfsConnect - Connect to a hdfs file system.
     * Connect to the hdfs.
     * @param nn   The NameNode.  See hdfsBuilderSetNameNode for details.
     * @param port The port on which the server is listening.
     * @return Returns a handle to the filesystem or NULL on error.
     * @deprecated Use hdfsBuilderConnect instead.
     */
    WIN32EXP hdfsFS hdfsConnect(const char* nn, tPort port);

    /**
     * hdfsConnect - Connect to an hdfs file system.
     *
     * Forces a new instance to be created
     *
     * @param nn     The NameNode.  See hdfsBuilderSetNameNode for details.
     * @param port   The port on which the server is listening.
     * @param user   The user name to use when connecting
     * @return       Returns a handle to the filesystem or NULL on error.
     * @deprecated   Use hdfsBuilderConnect instead.
     */
    WIN32EXP hdfsFS hdfsConnectAsUserNewInstance ( const char* nn, tPort port,
                                          const char *user );

    /**
     * hdfsConnect - Connect to an hdfs file system.
     *
     * Forces a new instance to be created
     *
     * @param nn     The NameNode.  See hdfsBuilderSetNameNode for details.
     * @param port   The port on which the server is listening.
     * @return       Returns a handle to the filesystem or NULL on error.
     * @deprecated   Use hdfsBuilderConnect instead.
     */
    WIN32EXP hdfsFS hdfsConnectNewInstance(const char* nn, tPort port);

    /**
     * Connect to HDFS using the parameters defined by the builder.
     *
     * The HDFS builder will be freed, whether or not the connection was
     * successful.
     *
     * Every successful call to hdfsBuilderConnect should be matched with a call
     * to hdfsDisconnect, when the hdfsFS is no longer needed.
     *
     * @param bld    The HDFS builder
     * @return       Returns a handle to the filesystem, or NULL on error.
     */
    WIN32EXP hdfsFS hdfsBuilderConnect(struct hdfsBuilder *bld);

    /**
     * Create an HDFS builder.
     *
     * @return The HDFS builder, or NULL on error.
     */
    WIN32EXP struct hdfsBuilder *hdfsNewBuilder(void);

    /**
     * Force the builder to always create a new instance of the FileSystem,
     * rather than possibly finding one in the cache.
     *
     * @param bld The HDFS builder
     */
    WIN32EXP void hdfsBuilderSetForceNewInstance(struct hdfsBuilder *bld);

    /**
     * Set the HDFS NameNode to connect to.
     *
     * @param bld  The HDFS builder
     * @param nn   The NameNode to use.
     *
     *             If the string given is 'default', the default NameNode
     *             configuration will be used (from the XML configuration files)
     *
     *             If NULL is given, a LocalFileSystem will be created.
     *
     *             If the string starts with a protocol type such as file:// or
     *             hdfs://, this protocol type will be used.  If not, the
     *             hdfs:// protocol type will be used.
     *
     *             You may specify a NameNode port in the usual way by
     *             passing a string of the format hdfs://<hostname>:<port>.
     *             Alternately, you may set the port with
     *             hdfsBuilderSetNameNodePort.  However, you must not pass the
     *             port in two different ways.
     */
    WIN32EXP void hdfsBuilderSetNameNode(struct hdfsBuilder *bld, const char *nn);

    /**
     * Set the port of the HDFS NameNode to connect to.
     *
     * @param bld The HDFS builder
     * @param port The port.
     */
    WIN32EXP void hdfsBuilderSetNameNodePort(struct hdfsBuilder *bld, tPort port);

    /**
     * Set the username to use when connecting to the HDFS cluster.
     *
     * @param bld The HDFS builder
     * @param userName The user name.  The string will be shallow-copied.
     */
    WIN32EXP void hdfsBuilderSetUserName(struct hdfsBuilder *bld, const char *userName);

    /**
     * Set the path to the Kerberos ticket cache to use when connecting to
     * the HDFS cluster.
     *
     * @param bld The HDFS builder
     * @param kerbTicketCachePath The Kerberos ticket cache path.  The string
     *                            will be shallow-copied.
     */
    WIN32EXP void hdfsBuilderSetKerbTicketCachePath(struct hdfsBuilder *bld,
                                   const char *kerbTicketCachePath);

    /**
     * Free an HDFS builder.
     *
     * It is normally not necessary to call this function since
     * hdfsBuilderConnect frees the builder.
     *
     * @param bld The HDFS builder
     */
    WIN32EXP void hdfsFreeBuilder(struct hdfsBuilder *bld);

    /**
     * Set a configuration string for an HdfsBuilder.
     *
     * @param key      The key to set.
     * @param val      The value, or NULL to set no value.
     *                 This will be shallow-copied.  You are responsible for
     *                 ensuring that it remains valid until the builder is
     *                 freed.
     *
     * @return         0 on success; nonzero error code otherwise.
     */
    WIN32EXP int hdfsBuilderConfSetStr(struct hdfsBuilder *bld, const char *key,
                              const char *val);

    /**
     * Get a configuration string.
     *
     * @param key      The key to find
     * @param val      (out param) The value.  This will be set to NULL if the
     *                 key isn't found.  You must free this string with
     *                 hdfsConfStrFree.
     *
     * @return         0 on success; nonzero error code otherwise.
     *                 Failure to find the key is not an error.
     */
    WIN32EXP int hdfsConfGetStr(const char *key, char **val);

    /**
     * Get a configuration integer.
     *
     * @param key      The key to find
     * @param val      (out param) The value.  This will NOT be changed if the
     *                 key isn't found.
     *
     * @return         0 on success; nonzero error code otherwise.
     *                 Failure to find the key is not an error.
     */
    WIN32EXP int hdfsConfGetInt(const char *key, int32_t *val);

    /**
     * Free a configuration string found with hdfsConfGetStr.
     *
     * @param val      A configuration string obtained from hdfsConfGetStr
     */
    WIN32EXP void hdfsConfStrFree(char *val);

    /**
     * hdfsDisconnect - Disconnect from the hdfs file system.
     * Disconnect from hdfs.
     * @param fs The configured filesystem handle.
     * @return Returns 0 on success, -1 on error.
     *         Even if there is an error, the resources associated with the
     *         hdfsFS will be freed.
     */
    WIN32EXP int hdfsDisconnect(hdfsFS fs);


    /**
     * hdfsOpenFile - Open a hdfs file in given mode.
     * @param fs The configured filesystem handle.
     * @param path The full path to the file.
     * @param flags - an | of bits/fcntl.h file flags - supported flags are O_RDONLY, O_WRONLY (meaning create or overwrite i.e., implies O_TRUNCAT),
     * O_WRONLY|O_APPEND. Other flags are generally ignored other than (O_RDWR || (O_EXCL & O_CREAT)) which return NULL and set errno equal ENOTSUP.
     * @param bufferSize Size of buffer for read/write - pass 0 if you want
     * to use the default configured values.
     * @param replication Block replication - pass 0 if you want to use
     * the default configured values.
     * @param blocksize Size of block - pass 0 if you want to use the
     * default configured values.
     * @return Returns the handle to the open file or NULL on error.
     */
    WIN32EXP hdfsFile hdfsOpenFile(hdfsFS fs, const char* path, int flags,
                          int bufferSize, short replication, tSize blocksize);


    /**
     * hdfsCloseFile - Close an open file.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @return Returns 0 on success, -1 on error.
     *         On error, errno will be set appropriately.
     *         If the hdfs file was valid, the memory associated with it will
     *         be freed at the end of this call, even if there was an I/O
     *         error.
     */
    WIN32EXP int hdfsCloseFile(hdfsFS fs, hdfsFile file);


    /**
     * hdfsExists - Checks if a given path exsits on the filesystem
     * @param fs The configured filesystem handle.
     * @param path The path to look for
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsExists(hdfsFS fs, const char *path);


    /**
     * hdfsSeek - Seek to given offset in file.
     * This works only for files opened in read-only mode.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @param desiredPos Offset into the file to seek into.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsSeek(hdfsFS fs, hdfsFile file, tOffset desiredPos);


    /**
     * hdfsTell - Get the current offset in the file, in bytes.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @return Current offset, -1 on error.
     */
    WIN32EXP tOffset hdfsTell(hdfsFS fs, hdfsFile file);


    /**
     * hdfsRead - Read data from an open file.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @param buffer The buffer to copy read bytes into.
     * @param length The length of the buffer.
     * @return      On success, a positive number indicating how many bytes
     *              were read.
     *              On end-of-file, 0.
     *              On error, -1.  Errno will be set to the error code.
     *              Just like the POSIX read function, hdfsRead will return -1
     *              and set errno to EINTR if data is temporarily unavailable,
     *              but we are not yet at the end of the file.
     */
    WIN32EXP tSize hdfsRead(hdfsFS fs, hdfsFile file, void* buffer, tSize length);

    /**
     * hdfsPread - Positional read of data from an open file.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @param position Position from which to read
     * @param buffer The buffer to copy read bytes into.
     * @param length The length of the buffer.
     * @return      See hdfsRead
     */
    WIN32EXP tSize hdfsPread(hdfsFS fs, hdfsFile file, tOffset position,
                    void* buffer, tSize length);


    /**
     * hdfsWrite - Write data into an open file.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @param buffer The data.
     * @param length The no. of bytes to write.
     * @return Returns the number of bytes written, -1 on error.
     */
    WIN32EXP tSize hdfsWrite(hdfsFS fs, hdfsFile file, const void* buffer,
                    tSize length);


    /**
     * hdfsWrite - Flush the data.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsFlush(hdfsFS fs, hdfsFile file);


    /**
     * hdfsHFlush - Flush out the data in client's user buffer. After the
     * return of this call, new readers will see the data.
     * @param fs configured filesystem handle
     * @param file file handle
     * @return 0 on success, -1 on error and sets errno
     */
    WIN32EXP int hdfsHFlush(hdfsFS fs, hdfsFile file);


    /**
     * hdfsHSync - Similar to posix fsync, Flush out the data in client's
     * user buffer. all the way to the disk device (but the disk may have
     * it in its cache).
     * @param fs configured filesystem handle
     * @param file file handle
     * @return 0 on success, -1 on error and sets errno
     */
    WIN32EXP int hdfsHSync(hdfsFS fs, hdfsFile file);


    /**
     * hdfsAvailable - Number of bytes that can be read from this
     * input stream without blocking.
     * @param fs The configured filesystem handle.
     * @param file The file handle.
     * @return Returns available bytes; -1 on error.
     */
    WIN32EXP int hdfsAvailable(hdfsFS fs, hdfsFile file);


    /**
     * hdfsCopy - Copy file from one filesystem to another.
     * @param srcFS The handle to source filesystem.
     * @param src The path of source file.
     * @param dstFS The handle to destination filesystem.
     * @param dst The path of destination file.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsCopy(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);


    /**
     * hdfsMove - Move file from one filesystem to another.
     * @param srcFS The handle to source filesystem.
     * @param src The path of source file.
     * @param dstFS The handle to destination filesystem.
     * @param dst The path of destination file.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsMove(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst);


    /**
     * hdfsDelete - Delete file.
     * @param fs The configured filesystem handle.
     * @param path The path of the file.
     * @param recursive if path is a directory and set to
     * non-zero, the directory is deleted else throws an exception. In
     * case of a file the recursive argument is irrelevant.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsDelete(hdfsFS fs, const char* path, int recursive);

    /**
     * hdfsRename - Rename file.
     * @param fs The configured filesystem handle.
     * @param oldPath The path of the source file.
     * @param newPath The path of the destination file.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsRename(hdfsFS fs, const char* oldPath, const char* newPath);


    /**
     * hdfsGetWorkingDirectory - Get the current working directory for
     * the given filesystem.
     * @param fs The configured filesystem handle.
     * @param buffer The user-buffer to copy path of cwd into.
     * @param bufferSize The length of user-buffer.
     * @return Returns buffer, NULL on error.
     */
    WIN32EXP char* hdfsGetWorkingDirectory(hdfsFS fs, char *buffer, size_t bufferSize);


    /**
     * hdfsSetWorkingDirectory - Set the working directory. All relative
     * paths will be resolved relative to it.
     * @param fs The configured filesystem handle.
     * @param path The path of the new 'cwd'.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsSetWorkingDirectory(hdfsFS fs, const char* path);


    /**
     * hdfsCreateDirectory - Make the given file and all non-existent
     * parents into directories.
     * @param fs The configured filesystem handle.
     * @param path The path of the directory.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsCreateDirectory(hdfsFS fs, const char* path);


    /**
     * hdfsSetReplication - Set the replication of the specified
     * file to the supplied value
     * @param fs The configured filesystem handle.
     * @param path The path of the file.
     * @return Returns 0 on success, -1 on error.
     */
    WIN32EXP int hdfsSetReplication(hdfsFS fs, const char* path, int16_t replication);

    /**
     * hdfsFileInfo - Information about a file/directory.
     */
    typedef struct  {
        tObjectKind mKind;   /* file or directory */
        char *mName;         /* the name of the file */
        tTime mLastMod;      /* the last modification time for the file in seconds */
        tOffset mSize;       /* the size of the file in bytes */
        short mReplication;    /* the count of replicas */
        tOffset mBlockSize;  /* the block size for the file */
        char *mOwner;        /* the owner of the file */
        char *mGroup;        /* the group associated with the file */
        short mPermissions;  /* the permissions associated with the file */
        tTime mLastAccess;    /* the last access time for the file in seconds */
    } hdfsFileInfo;

    /**
     * hdfsListDirectory - Get list of files/directories for a given
     * directory-path. hdfsFreeFileInfo should be called to deallocate memory.
     * @param fs The configured filesystem handle.
     * @param path The path of the directory.
     * @param numEntries Set to the number of files/directories in path.
     * @return Returns a dynamically-allocated array of hdfsFileInfo
     * objects; NULL on error.
     */
    WIN32EXP hdfsFileInfo *hdfsListDirectory(hdfsFS fs, const char* path,
                                    int *numEntries);

    /**
     * hdfsGetPathInfo - Get information about a path as a (dynamically
     * allocated) single hdfsFileInfo struct. hdfsFreeFileInfo should be
     * called when the pointer is no longer needed.
     * @param fs The configured filesystem handle.
     * @param path The path of the file.
     * @return Returns a dynamically-allocated hdfsFileInfo object;
     * NULL on error.
     */
    WIN32EXP hdfsFileInfo *hdfsGetPathInfo(hdfsFS fs, const char* path);


    /**
     * hdfsFreeFileInfo - Free up the hdfsFileInfo array (including fields)
     * @param hdfsFileInfo The array of dynamically-allocated hdfsFileInfo
     * objects.
     * @param numEntries The size of the array.
     */
    WIN32EXP void hdfsFreeFileInfo(hdfsFileInfo *hdfsFileInfo, int numEntries);


    /**
     * hdfsGetHosts - Get hostnames where a particular block (determined by
     * pos & blocksize) of a file is stored. The last element in the array
     * is NULL. Due to replication, a single block could be present on
     * multiple hosts.
     * @param fs The configured filesystem handle.
     * @param path The path of the file.
     * @param start The start of the block.
     * @param length The length of the block.
     * @return Returns a dynamically-allocated 2-d array of blocks-hosts;
     * NULL on error.
     */
    WIN32EXP char*** hdfsGetHosts(hdfsFS fs, const char* path,
                     tOffset start, tOffset length);


    /**
     * hdfsFreeHosts - Free up the structure returned by hdfsGetHosts
     * @param hdfsFileInfo The array of dynamically-allocated hdfsFileInfo
     * objects.
     * @param numEntries The size of the array.
     */
    WIN32EXP void hdfsFreeHosts(char ***blockHosts);


    /**
     * hdfsGetDefaultBlockSize - Get the default blocksize.
     *
     * @param fs            The configured filesystem handle.
     * @deprecated          Use hdfsGetDefaultBlockSizeAtPath instead.
     *
     * @return              Returns the default blocksize, or -1 on error.
     */
    WIN32EXP tOffset hdfsGetDefaultBlockSize(hdfsFS fs);


    /**
     * hdfsGetDefaultBlockSizeAtPath - Get the default blocksize at the
     * filesystem indicated by a given path.
     *
     * @param fs            The configured filesystem handle.
     * @param path          The given path will be used to locate the actual
     *                      filesystem.  The full path does not have to exist.
     *
     * @return              Returns the default blocksize, or -1 on error.
     */
    WIN32EXP tOffset hdfsGetDefaultBlockSizeAtPath(hdfsFS fs, const char *path);


    /**
     * hdfsGetCapacity - Return the raw capacity of the filesystem.
     * @param fs The configured filesystem handle.
     * @return Returns the raw-capacity; -1 on error.
     */
    WIN32EXP tOffset hdfsGetCapacity(hdfsFS fs);


    /**
     * hdfsGetUsed - Return the total raw size of all files in the filesystem.
     * @param fs The configured filesystem handle.
     * @return Returns the total-size; -1 on error.
     */
    WIN32EXP tOffset hdfsGetUsed(hdfsFS fs);

    /**
     * Change the user and/or group of a file or directory.
     *
     * @param fs            The configured filesystem handle.
     * @param path          the path to the file or directory
     * @param owner         User string.  Set to NULL for 'no change'
     * @param group         Group string.  Set to NULL for 'no change'
     * @return              0 on success else -1
     */
    WIN32EXP int hdfsChown(hdfsFS fs, const char* path, const char *owner,
                  const char *group);

    /**
     * hdfsChmod
     * @param fs The configured filesystem handle.
     * @param path the path to the file or directory
     * @param mode the bitmask to set it to
     * @return 0 on success else -1
     */
    WIN32EXP int hdfsChmod(hdfsFS fs, const char* path, short mode);

    /**
     * hdfsUtime
     * @param fs The configured filesystem handle.
     * @param path the path to the file or directory
     * @param mtime new modification time or -1 for no change
     * @param atime new access time or -1 for no change
     * @return 0 on success else -1
     */
    WIN32EXP int hdfsUtime(hdfsFS fs, const char* path, tTime mtime, tTime atime);

#ifdef __cplusplus
}
#endif

#endif /*LIBHDFS_HDFS_H*/

/**
 * vim: ts=4: sw=4: et
 */