All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 47962f80 authored by Kirk Webb's avatar Kirk Webb

Looks big and scary, and probably is. This checkin includes all the

cruft needed to compile ntfs support into imagezip, including the i18n
unicode library
routines from FBSD 5.0.  Most of the magic is in the makefiles, but there
is a patch for the ntfsprogs package we're using to get NTFS support.
(patch contributed by Russ).

Note that the ntfsprogs tarball is located in emulab webspace (like TG).

Don't worry!  You still have to pass --enable-windows to configure in order to
pull any of this in, although it should compile nicely from here on out.

Russ will commit his imagezip changes (hiber, and page file skipping) soon.
parent 8673563a
......@@ -8,36 +8,26 @@ SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../../..
SUBDIR = os/imagezip/ntfs
LIBDIR = $(SRCDIR)/linux-ntfs
include $(OBJDIR)/Makeconf
CC = gcc30
INCS = -I$(SRCDIR)/extra_bsd_includes -I$(LIBDIR)/include \
-I$(LIBDIR) -I$(SRCDIR)/..
CFLAGS = -O2 -g -static $(INCS)
all: $(LIBDIR) libntfs.a
all: libntfs.a liblocale.a
include $(TESTBED_SRCDIR)/GNUmakerules
libntfs.a: missingClibrary.o linux-ntfs/libntfs/.libs/libntfs.a
cp -p linux-ntfs/libntfs/.libs/libntfs.a libntfs.a
ar r libntfs.a missingClibrary.o
libntfs.a: libntfs/libntfs.a
cp -p libntfs/libntfs.a libntfs.a
linux-ntfs/libntfs/.libs/libntfs.a: linux-ntfs/config.status
@$(MAKE) -C linux-ntfs/libntfs CC="$(CC)" CFLAGS="$(CFLAGS)" all
liblocale.a: liblocale/liblocale.a
cp -p liblocale/liblocale.a liblocale.a
linux-ntfs/config.status:
-mkdir linux-ntfs
(cd linux-ntfs; $(LIBDIR)/configure --srcdir=$(LIBDIR))
libntfs/libntfs.a:
@$(MAKE) -C libntfs
$(LIBDIR):
@echo ""
@echo "* * * must install linux-ntfs source first * * *"
@echo ""
@false
liblocale/liblocale.a:
@$(MAKE) -C liblocale
clean:
$(MAKE) -C linux-ntfs/libntfs clean
/bin/rm -f missingClibrary.o libntfs.a
-$(MAKE) -C libntfs clean
-$(MAKE) -C liblocale clean
/bin/rm -f libntfs.a liblocale.a
#ifndef _LINUX_TYPES_H
#define _LINUX_TYPES_H
#include<sys/types.h>
typedef u_int8_t __u8;
typedef u_int16_t __u16;
typedef u_int32_t __u32;
typedef u_int64_t __u64;
typedef int8_t __s8;
typedef int16_t __s16;
typedef int32_t __s32;
typedef int64_t __s64;
#endif /* _LINUX_TYPES_H */
# from @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
# $FreeBSD: src/lib/libc/locale/Makefile.inc,v 1.42 2002/11/18 09:50:55 ru Exp $
# locale sources
#.PATH: ${.CURDIR}/${MACHINE_ARCH}/locale ${.CURDIR}/locale
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../../../..
SUBDIR = os/imagezip/ntfs/liblocale
include $(OBJDIR)/Makeconf
all: liblocale.a
include $(TESTBED_SRCDIR)/GNUmakerules
CC = gcc
CFLAGS += -O2 -g -static -Wall -I${OBJDIR} -I/usr/local/include \
-I${SRCDIR}/include
OBJS= big5.o btowc.o collate.o collcmp.o euc.o fix_grouping.o frune.o \
isctype.o iswctype.o \
ldpart.o lmessages.o lmonetary.o lnumeric.o localeconv.o mblen.o \
mbrlen.o \
mbrtowc.o mbrune.o mbsinit.o mbsrtowcs.o mbtowc.o mbstowcs.o \
mskanji.o nl_langinfo.o nomacros.o none.o rune.o \
runetype.o setinvalidrune.o setlocale.o setrunelocale.o table.o \
tolower.o toupper.o utf2.o utf8.o wcrtomb.o wcsrtombs.o wcsftime.o \
wcstod.o \
wcstoimax.o wcstol.o wcstoll.o \
wcstombs.o \
wcstoul.o wcstoull.o wcstoumax.o wctob.o wctomb.o wctrans.o wctype.o \
wcwidth.o
liblocale.a: $(OBJS)
$(AR) crv $@ $(OBJS)
$(RANLIB) $@
clean:
-rm -f *.o *~ *.a
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)big5.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/big5.c,v 1.7 2002/03/22 21:52:18 obrien Exp $");
#include <rune.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
rune_t _BIG5_sgetrune(const char *, size_t, char const **);
int _BIG5_sputrune(rune_t, char *, size_t, char **);
int
_BIG5_init(rl)
_RuneLocale *rl;
{
rl->sgetrune = _BIG5_sgetrune;
rl->sputrune = _BIG5_sputrune;
_CurrentRuneLocale = rl;
__mb_cur_max = 2;
return (0);
}
static inline int
_big5_check(c)
u_int c;
{
c &= 0xff;
return ((c >= 0xa1 && c <= 0xfe) ? 2 : 1);
}
rune_t
_BIG5_sgetrune(string, n, result)
const char *string;
size_t n;
char const **result;
{
rune_t rune = 0;
int len;
if (n < 1 || (len = _big5_check(*string)) > n) {
if (result)
*result = string;
return (_INVALID_RUNE);
}
while (--len >= 0)
rune = (rune << 8) | ((u_int)(*string++) & 0xff);
if (result)
*result = string;
return rune;
}
int
_BIG5_sputrune(c, string, n, result)
rune_t c;
char *string, **result;
size_t n;
{
if (c & 0x8000) {
if (n >= 2) {
string[0] = (c >> 8) & 0xff;
string[1] = c & 0xff;
if (result)
*result = string + 2;
return (2);
}
}
else {
if (n >= 1) {
*string = c & 0xff;
if (result)
*result = string + 1;
return (1);
}
}
if (result)
*result = string;
return (0);
}
/*-
* Copyright (c) 2002 Tim J. Robbins.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/btowc.c,v 1.1 2002/08/03 13:49:55 tjr Exp $");
#include <rune.h>
#include <wchar.h>
wint_t
btowc(int c)
{
rune_t r;
char cc;
if (c == EOF)
return (WEOF);
cc = (char)c;
if ((r = sgetrune(&cc, 1, NULL)) == _INVALID_RUNE)
return (WEOF);
return (r);
}
/*-
* Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
* at Electronni Visti IA, Kiev, Ukraine.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/collate.c,v 1.32 2002/10/29 09:03:57 tjr Exp $");
#include "namespace.h"
#include <arpa/inet.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sysexits.h>
#include "un-namespace.h"
#include "collate.h"
#include "setlocale.h"
#include "ldpart.h"
#include "libc_private.h"
int __collate_load_error = 1;
int __collate_substitute_nontrivial;
u_char __collate_substitute_table[UCHAR_MAX + 1][STR_LEN];
struct __collate_st_char_pri __collate_char_pri_table[UCHAR_MAX + 1];
struct __collate_st_chain_pri *__collate_chain_pri_table;
void __collate_err(int ex, const char *f) __dead2;
int
__collate_load_tables(const char *encoding)
{
FILE *fp;
int i, saverr, chains;
uint32_t u32;
char strbuf[STR_LEN], buf[PATH_MAX];
void *TMP_substitute_table, *TMP_char_pri_table, *TMP_chain_pri_table;
static char collate_encoding[ENCODING_LEN + 1];
/* 'encoding' must be already checked. */
if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
__collate_load_error = 1;
return (_LDP_CACHE);
}
/*
* If the locale name is the same as our cache, use the cache.
*/
if (strcmp(encoding, collate_encoding) == 0) {
__collate_load_error = 0;
return (_LDP_CACHE);
}
/*
* Slurp the locale file into the cache.
*/
/* 'PathLocale' must be already set & checked. */
/* Range checking not needed, encoding has fixed size */
(void)strcpy(buf, _PathLocale);
(void)strcat(buf, "/");
(void)strcat(buf, encoding);
(void)strcat(buf, "/LC_COLLATE");
if ((fp = fopen(buf, "r")) == NULL)
return (_LDP_ERROR);
if (fread(strbuf, sizeof(strbuf), 1, fp) != 1) {
saverr = errno;
(void)fclose(fp);
errno = saverr;
return (_LDP_ERROR);
}
chains = -1;
if (strcmp(strbuf, COLLATE_VERSION) == 0)
chains = 0;
else if (strcmp(strbuf, COLLATE_VERSION1_1) == 0)
chains = 1;
if (chains < 0) {
(void)fclose(fp);
errno = EFTYPE;
return (_LDP_ERROR);
}
if (chains) {
if (fread(&u32, sizeof(u32), 1, fp) != 1) {
saverr = errno;
(void)fclose(fp);
errno = saverr;
return (_LDP_ERROR);
}
if ((chains = (int)ntohl(u32)) < 1) {
(void)fclose(fp);
errno = EFTYPE;
return (_LDP_ERROR);
}
} else
chains = TABLE_SIZE;
if ((TMP_substitute_table =
malloc(sizeof(__collate_substitute_table))) == NULL) {
saverr = errno;
(void)fclose(fp);
errno = saverr;
return (_LDP_ERROR);
}
if ((TMP_char_pri_table =
malloc(sizeof(__collate_char_pri_table))) == NULL) {
saverr = errno;
free(TMP_substitute_table);
(void)fclose(fp);
errno = saverr;
return (_LDP_ERROR);
}
if ((TMP_chain_pri_table =
malloc(sizeof(*__collate_chain_pri_table) * chains)) == NULL) {
saverr = errno;
free(TMP_substitute_table);
free(TMP_char_pri_table);
(void)fclose(fp);
errno = saverr;
return (_LDP_ERROR);
}
#define FREAD(a, b, c, d) \
{ \
if (fread(a, b, c, d) != c) { \
saverr = errno; \
free(TMP_substitute_table); \
free(TMP_char_pri_table); \
free(TMP_chain_pri_table); \
(void)fclose(d); \
errno = saverr; \
return (_LDP_ERROR); \
} \
}
FREAD(TMP_substitute_table, sizeof(__collate_substitute_table), 1, fp);
FREAD(TMP_char_pri_table, sizeof(__collate_char_pri_table), 1, fp);
FREAD(TMP_chain_pri_table,
sizeof(*__collate_chain_pri_table), chains, fp);
(void)fclose(fp);
(void)strcpy(collate_encoding, encoding);
if (__collate_substitute_table_ptr != NULL)
free(__collate_substitute_table_ptr);
__collate_substitute_table_ptr = TMP_substitute_table;
if (__collate_char_pri_table_ptr != NULL)
free(__collate_char_pri_table_ptr);
__collate_char_pri_table_ptr = TMP_char_pri_table;
if (__collate_chain_pri_table != NULL)
free(__collate_chain_pri_table);
__collate_chain_pri_table = TMP_chain_pri_table;
__collate_substitute_nontrivial = 0;
for (i = 0; i < UCHAR_MAX + 1; i++) {
if (__collate_substitute_table[i][0] != i ||
__collate_substitute_table[i][1] != 0) {
__collate_substitute_nontrivial = 1;
break;
}
}
__collate_load_error = 0;
return (_LDP_LOADED);
}
u_char *
__collate_substitute(s)
const u_char *s;
{
int dest_len, len, nlen;
int delta = strlen(s);
u_char *dest_str = NULL;
if (s == NULL || *s == '\0')
return (__collate_strdup(""));
delta += delta / 8;
dest_str = malloc(dest_len = delta);
if (dest_str == NULL)
__collate_err(EX_OSERR, __FUNCTION__);
len = 0;
while (*s) {
nlen = len + strlen(__collate_substitute_table[*s]);
if (dest_len <= nlen) {
dest_str = reallocf(dest_str, dest_len = nlen + delta);
if (dest_str == NULL)
__collate_err(EX_OSERR, __FUNCTION__);
}
(void)strcpy(dest_str + len, __collate_substitute_table[*s++]);
len = nlen;
}
return (dest_str);
}
void
__collate_lookup(t, len, prim, sec)
const u_char *t;
int *len, *prim, *sec;
{
struct __collate_st_chain_pri *p2;
*len = 1;
*prim = *sec = 0;
for (p2 = __collate_chain_pri_table; p2->str[0] != '\0'; p2++) {
if (*t == p2->str[0] &&
strncmp(t, p2->str, strlen(p2->str)) == 0) {
*len = strlen(p2->str);
*prim = p2->prim;
*sec = p2->sec;
return;
}
}
*prim = __collate_char_pri_table[*t].prim;
*sec = __collate_char_pri_table[*t].sec;
}
u_char *
__collate_strdup(s)
u_char *s;
{
u_char *t = strdup(s);
if (t == NULL)
__collate_err(EX_OSERR, __FUNCTION__);
return (t);
}
void
__collate_err(int ex, const char *f)
{
const char *s;
int serrno = errno;
s = _getprogname();
_write(STDERR_FILENO, s, strlen(s));
_write(STDERR_FILENO, ": ", 2);
s = f;
_write(STDERR_FILENO, s, strlen(s));
_write(STDERR_FILENO, ": ", 2);
s = strerror(serrno);
_write(STDERR_FILENO, s, strlen(s));
_write(STDERR_FILENO, "\n", 1);
exit(ex);
}
#ifdef COLLATE_DEBUG
void
__collate_print_tables()
{
int i;
struct __collate_st_chain_pri *p2;
printf("Substitute table:\n");
for (i = 0; i < UCHAR_MAX + 1; i++)
if (i != *__collate_substitute_table[i])
printf("\t'%c' --> \"%s\"\n", i,
__collate_substitute_table[i]);
printf("Chain priority table:\n");
for (p2 = __collate_chain_pri_table; p2->str[0] != '\0'; p2++)
printf("\t\"%s\" : %d %d\n", p2->str, p2->prim, p2->sec);
printf("Char priority table:\n");
for (i = 0; i < UCHAR_MAX + 1; i++)
printf("\t'%c' : %d %d\n", i, __collate_char_pri_table[i].prim,
__collate_char_pri_table[i].sec);
}
#endif
/*
* Copyright (C) 1996 by Andrey A. Chernov, Moscow, Russia.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/collcmp.c,v 1.14 2002/03/22 21:52:18 obrien Exp $");
#define ASCII_COMPATIBLE_COLLATE /* see share/colldef */
#include <string.h>
#include "collate.h"
#ifndef ASCII_COMPATIBLE_COLLATE
#include <ctype.h>
#endif
/*
* Compare two characters converting collate information
* into ASCII-compatible range, it allows to handle
* "[a-z]"-type ranges with national characters.
*/
int __collate_range_cmp (c1, c2)
int c1, c2;
{
static char s1[2], s2[2];
int ret;
#ifndef ASCII_COMPATIBLE_COLLATE