Add missing cred.h functions
Resolve compiler warning with kmem_free (unused len) Add stub for byteorder.h Add zlib shim for compress2 and uncompress functions git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@29 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
This commit is contained in:
parent
b0dd3380aa
commit
3b3ba48fe9
|
@ -0,0 +1,4 @@
|
||||||
|
#ifndef _SPL_ZMOD_H
|
||||||
|
#define _SPL_ZMOD_H
|
||||||
|
|
||||||
|
#endif /* SPL_ZMOD_H */
|
|
@ -33,9 +33,35 @@ typedef struct cred {
|
||||||
/* auditinfo_addr_t cr_auinfo; audit info */
|
/* auditinfo_addr_t cr_auinfo; audit info */
|
||||||
} cred_t;
|
} cred_t;
|
||||||
|
|
||||||
|
#define kcred NULL
|
||||||
|
#define CRED() NULL
|
||||||
|
|
||||||
|
static __inline__ uid_t
|
||||||
|
crgetuid(cred_t *cr)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline__ gid_t
|
||||||
|
crgetgid(cred_t *cr)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline__ int
|
||||||
|
crgetngroups(cred_t *cr)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static __inline__ gid_t *
|
||||||
|
crgetgroups(cred_t *cr)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _SPL_CRED_H */
|
#endif /* _SPL_CRED_H */
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ extern unsigned int kmem_alloc_max;
|
||||||
|
|
||||||
#define kmem_free(ptr, size) \
|
#define kmem_free(ptr, size) \
|
||||||
({ \
|
({ \
|
||||||
BUG_ON(!ptr); \
|
BUG_ON(!ptr || size < 0); \
|
||||||
atomic_sub((size), &kmem_alloc_used); \
|
atomic_sub((size), &kmem_alloc_used); \
|
||||||
memset(ptr, 0x5a, (size)); /* Poison */ \
|
memset(ptr, 0x5a, (size)); /* Poison */ \
|
||||||
kfree(ptr); \
|
kfree(ptr); \
|
||||||
|
@ -70,7 +70,11 @@ extern unsigned int kmem_alloc_max;
|
||||||
|
|
||||||
#define kmem_alloc(size, flags) kmalloc(size, flags)
|
#define kmem_alloc(size, flags) kmalloc(size, flags)
|
||||||
#define kmem_zalloc(size, flags) kzalloc(size, flags)
|
#define kmem_zalloc(size, flags) kzalloc(size, flags)
|
||||||
#define kmem_free(ptr, size) kfree(ptr)
|
#define kmem_free(ptr, size) \
|
||||||
|
({ \
|
||||||
|
BUG_ON(!ptr || size < 0); \
|
||||||
|
kfree(ptr); \
|
||||||
|
})
|
||||||
|
|
||||||
#endif /* DEBUG_KMEM */
|
#endif /* DEBUG_KMEM */
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,14 @@ extern "C" {
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
|
|
||||||
#define INT32_MAX INT_MAX
|
#define INT32_MAX INT_MAX
|
||||||
#define UINT64_MAX (~0ULL)
|
#define INT32_MIN INT_MIN
|
||||||
|
#define UINT32_MAX UINT_MAX
|
||||||
|
#define UINT32_MIN UINT_MIN
|
||||||
|
#define INT64_MAX LLONG_MAX
|
||||||
|
#define INT64_MIN LLONG_MIN
|
||||||
|
#define UINT64_MAX ULLONG_MAX
|
||||||
|
#define UINT64_MIN ULLONG_MIN
|
||||||
|
|
||||||
#define NBBY 8
|
#define NBBY 8
|
||||||
#define ENOTSUP ENOTSUPP
|
#define ENOTSUP ENOTSUPP
|
||||||
|
|
||||||
|
@ -98,22 +105,22 @@ extern "C" {
|
||||||
#ifdef DTRACE_PROBE1
|
#ifdef DTRACE_PROBE1
|
||||||
#undef DTRACE_PROBE1
|
#undef DTRACE_PROBE1
|
||||||
#endif /* DTRACE_PROBE1 */
|
#endif /* DTRACE_PROBE1 */
|
||||||
#define DTRACE_PROBE1(a, b, c) ((void)0)
|
#define DTRACE_PROBE1(a, b, c) ((void)0)
|
||||||
|
|
||||||
#ifdef DTRACE_PROBE2
|
#ifdef DTRACE_PROBE2
|
||||||
#undef DTRACE_PROBE2
|
#undef DTRACE_PROBE2
|
||||||
#endif /* DTRACE_PROBE2 */
|
#endif /* DTRACE_PROBE2 */
|
||||||
#define DTRACE_PROBE2(a, b, c, d, e) ((void)0)
|
#define DTRACE_PROBE2(a, b, c, d, e) ((void)0)
|
||||||
|
|
||||||
#ifdef DTRACE_PROBE3
|
#ifdef DTRACE_PROBE3
|
||||||
#undef DTRACE_PROBE3
|
#undef DTRACE_PROBE3
|
||||||
#endif /* DTRACE_PROBE3 */
|
#endif /* DTRACE_PROBE3 */
|
||||||
#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void)0)
|
#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void)0)
|
||||||
|
|
||||||
#ifdef DTRACE_PROBE4
|
#ifdef DTRACE_PROBE4
|
||||||
#undef DTRACE_PROBE4
|
#undef DTRACE_PROBE4
|
||||||
#endif /* DTRACE_PROBE4 */
|
#endif /* DTRACE_PROBE4 */
|
||||||
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void)0)
|
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void)0)
|
||||||
|
|
||||||
/* Missing globals */
|
/* Missing globals */
|
||||||
extern int p0;
|
extern int p0;
|
||||||
|
@ -122,6 +129,8 @@ extern int p0;
|
||||||
extern int highbit(unsigned long i);
|
extern int highbit(unsigned long i);
|
||||||
|
|
||||||
#define makedevice(maj,min) makedev(maj,min)
|
#define makedevice(maj,min) makedev(maj,min)
|
||||||
|
#define zone_dataset_visible(x, y) (1)
|
||||||
|
#define INGLOBALZONE(z) (1)
|
||||||
|
|
||||||
/* XXX - Borrowed from zfs project libsolcompat/include/sys/sysmacros.h */
|
/* XXX - Borrowed from zfs project libsolcompat/include/sys/sysmacros.h */
|
||||||
/* common macros */
|
/* common macros */
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
#ifndef _SPL_ZMOD_H
|
||||||
|
#define _SPL_ZMOD_H
|
||||||
|
|
||||||
|
#include <linux/zlib.h>
|
||||||
|
|
||||||
|
/* NOTE: z_compress_level/z_uncompress are nearly identical copies of
|
||||||
|
* the compress2/uncompress functions provided by the official zlib
|
||||||
|
* package available at http://zlib.net/. The only changes made we to
|
||||||
|
* slightly adapt the functioned called to match the linux kernel
|
||||||
|
* implementation of zlib.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Compresses the source buffer into the destination buffer. The level
|
||||||
|
* parameter has the same meaning as in deflateInit. sourceLen is the byte
|
||||||
|
* length of the source buffer. Upon entry, destLen is the total size of the
|
||||||
|
* destination buffer, which must be at least 0.1% larger than sourceLen plus
|
||||||
|
* 12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
|
||||||
|
*
|
||||||
|
* compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
|
* memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||||
|
* Z_STREAM_ERROR if the level parameter is invalid.
|
||||||
|
*/
|
||||||
|
static __inline__ int
|
||||||
|
z_compress_level(Byte *dest, uLong *destLen, const Byte *source,
|
||||||
|
uLong sourceLen, int level)
|
||||||
|
{
|
||||||
|
z_stream stream;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
stream.next_in = (Byte *)source;
|
||||||
|
stream.avail_in = (uInt)sourceLen;
|
||||||
|
#ifdef MAXSEG_64K
|
||||||
|
/* Check for source > 64K on 16-bit machine: */
|
||||||
|
if ((uLong)stream.avail_in != sourceLen)
|
||||||
|
return Z_BUF_ERROR;
|
||||||
|
#endif
|
||||||
|
stream.next_out = dest;
|
||||||
|
stream.avail_out = (uInt)*destLen;
|
||||||
|
|
||||||
|
if ((uLong)stream.avail_out != *destLen)
|
||||||
|
return Z_BUF_ERROR;
|
||||||
|
|
||||||
|
err = zlib_deflateInit(&stream, level);
|
||||||
|
if (err != Z_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = zlib_deflate(&stream, Z_FINISH);
|
||||||
|
if (err != Z_STREAM_END) {
|
||||||
|
zlib_deflateEnd(&stream);
|
||||||
|
return err == Z_OK ? Z_BUF_ERROR : err;
|
||||||
|
}
|
||||||
|
*destLen = stream.total_out;
|
||||||
|
|
||||||
|
err = zlib_deflateEnd(&stream);
|
||||||
|
return err;
|
||||||
|
} /* z_compress_level() */
|
||||||
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* Decompresses the source buffer into the destination buffer. sourceLen is
|
||||||
|
* the byte length of the source buffer. Upon entry, destLen is the total
|
||||||
|
* size of the destination buffer, which must be large enough to hold the
|
||||||
|
* entire uncompressed data. (The size of the uncompressed data must have
|
||||||
|
* been saved previously by the compressor and transmitted to the decompressor
|
||||||
|
* by some mechanism outside the scope of this compression library.)
|
||||||
|
* Upon exit, destLen is the actual size of the compressed buffer.
|
||||||
|
* This function can be used to decompress a whole file at once if the
|
||||||
|
* input file is mmap'ed.
|
||||||
|
*
|
||||||
|
* uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||||
|
* enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||||
|
* buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||||
|
*/
|
||||||
|
static __inline__ int
|
||||||
|
z_uncompress(Byte *dest, uLong *destLen, const Byte *source, uLong sourceLen)
|
||||||
|
{
|
||||||
|
z_stream stream;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
stream.next_in = (Byte *)source;
|
||||||
|
stream.avail_in = (uInt)sourceLen;
|
||||||
|
/* Check for source > 64K on 16-bit machine: */
|
||||||
|
if ((uLong)stream.avail_in != sourceLen)
|
||||||
|
return Z_BUF_ERROR;
|
||||||
|
|
||||||
|
stream.next_out = dest;
|
||||||
|
stream.avail_out = (uInt)*destLen;
|
||||||
|
|
||||||
|
if ((uLong)stream.avail_out != *destLen)
|
||||||
|
return Z_BUF_ERROR;
|
||||||
|
|
||||||
|
err = zlib_inflateInit(&stream);
|
||||||
|
if (err != Z_OK)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
err = zlib_inflate(&stream, Z_FINISH);
|
||||||
|
if (err != Z_STREAM_END) {
|
||||||
|
zlib_inflateEnd(&stream);
|
||||||
|
|
||||||
|
if (err == Z_NEED_DICT ||
|
||||||
|
(err == Z_BUF_ERROR && stream.avail_in == 0))
|
||||||
|
return Z_DATA_ERROR;
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
*destLen = stream.total_out;
|
||||||
|
|
||||||
|
err = zlib_inflateEnd(&stream);
|
||||||
|
return err;
|
||||||
|
} /* z_uncompress() */
|
||||||
|
|
||||||
|
#endif /* SPL_ZMOD_H */
|
Loading…
Reference in New Issue