Changes by: flatcap
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv7533
Added Files:
Makefile compat.c rl.c
Log Message:
test prog
--- NEW FILE ---
CC = gcc
RM = rm -f
KERNEL_SOURCE = /usr/src/linux
CFLAGS += -D__KERNEL__
CFLAGS += $(shell (cd ..; scripts/get_ntfs_driver_version))
CFLAGS += -Wall
CFLAGS += -Wstrict-prototypes
CFLAGS += -O2
CFLAGS += -fomit-frame-pointer
CFLAGS += -fno-strict-aliasing
CFLAGS += -pipe
CFLAGS += -mpreferred-stack-boundary=2
CFLAGS += -march=i686
CFLAGS += -I..
CFLAGS += -DMODULE
#CFLAGS += -DMODVERSIONS
#CFLAGS += -include $(KERNEL_SOURCE)/include/linux/modversions.h
CFLAGS += -DDEBUG
CFLAGS += -g
CFLAGS += -include ../scripts/ntfsextra.h
#-------------------------------------------------------------------------------
all: clean rl
.c.o:
$(CC) $(CFLAGS) -c $< -o $@
clean:
$(RM) rl
distclean: clean
tags:
ctags -R rl.c ../linux/fs/ntfs
--- NEW FILE ---
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
#include "src/types.h"
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
#define likely(x) __builtin_expect((x),1)
#define unlikely(x) __builtin_expect((x),0)
#define min(x,y) ({ \
const typeof(x) _x = (x); \
const typeof(y) _y = (y); \
(void) (&_x == &_y); \
_x < _y ? _x : _y; })
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
#define sle64_to_cpu(X) (X)
#define le16_to_cpu(X) (X)
#define le32_to_cpu(X) (X)
#define VMALLOC_OFFSET (8*1024*1024)
#define VMALLOC_START (((unsigned long) high_memory + 2*VMALLOC_OFFSET-1) & \
~(VMALLOC_OFFSET-1))
#define ntfs_debug(f, a...) \
do { \
printf(f, ##a); \
} while (0)
#define BUG() do { printf ("BUG: %s(%d)\n", __FILE__ , __LINE__ ); exit (1); } while(0)
unsigned long num_physpages;
void * high_memory;
static inline void *ERR_PTR(long error)
{
return (void *) error;
}
static inline long PTR_ERR(const void *ptr)
{
return (long) ptr;
}
static inline long IS_ERR(const void *ptr)
{
return (unsigned long)ptr > (unsigned long)-1000L;
}
struct super_block {
};
typedef struct {
struct super_block *sb;
u8 sector_size_bits;
u32 cluster_size;
u8 cluster_size_bits;
u8 major_ver;
} ntfs_volume;
typedef enum {
$UNUSED = 0,
$STANDARD_INFORMATION = 0x10,
$ATTRIBUTE_LIST = 0x20,
$FILE_NAME = 0x30,
$OBJECT_ID = 0x40,
$SECURITY_DESCRIPTOR = 0x50,
$VOLUME_NAME = 0x60,
$VOLUME_INFORMATION = 0x70,
$DATA = 0x80,
$INDEX_ROOT = 0x90,
$INDEX_ALLOCATION = 0xa0,
$BITMAP = 0xb0,
$REPARSE_POINT = 0xc0,
$EA_INFORMATION = 0xd0,
$EA = 0xe0,
$PROPERTY_SET = 0xf0,
$LOGGED_UTILITY_STREAM = 0x100,
$FIRST_USER_DEFINED_ATTRIBUTE = 0x1000,
$END = 0xffffffff,
} ATTR_TYPES;
typedef enum {
RESIDENT_ATTR_IS_INDEXED = 0x01,
} __attribute__ ((__packed__)) RESIDENT_ATTR_FLAGS;
typedef enum {
ATTR_IS_COMPRESSED = 0x0001,
ATTR_COMPRESSION_MASK = 0x00ff,
ATTR_IS_ENCRYPTED = 0x4000,
ATTR_IS_SPARSE = 0x8000,
} __attribute__ ((__packed__)) ATTR_FLAGS;
typedef struct {
/*Ofs*/
/* 0*/ ATTR_TYPES type; /* The (32-bit) type of the attribute. */
/* 4*/ u32 length; /* Byte size of the resident part of the
attribute (aligned to 8-byte boundary).
Used to get to the next attribute. */
/* 8*/ u8 non_resident; /* If 0, attribute is resident.
If 1, attribute is non-resident. */
/* 9*/ u8 name_length; /* Unicode character size of name of attribute.
0 if unnamed. */
/* 10*/ u16 name_offset; /* If name_length != 0, the byte offset to the
beginning of the name from the attribute
record. Note that the name is stored as a
Unicode string. When creating, place offset
just at the end of the record header. Then,
follow with attribute value or mapping pairs
array, resident and non-resident attributes
respectively, aligning to an 8-byte
boundary. */
/* 12*/ ATTR_FLAGS flags; /* Flags describing the attribute. */
/* 14*/ u16 instance; /* The instance of this attribute record. This
number is unique within this mft record (see
MFT_RECORD/next_attribute_instance notes in
in mft.h for more details). */
/* 16*/ union {
/* Resident attributes. */
struct {
/* 16 */ u32 value_length; /* Byte size of attribute value. */
/* 20 */ u16 value_offset; /* Byte offset of the attribute
value from the start of the
attribute record. When creating,
align to 8-byte boundary if we
have a name present as this might
not have a length of a multiple
of 8-bytes. */
/* 22 */ RESIDENT_ATTR_FLAGS resident_flags; /* See above. */
/* 23 */ s8 reservedR; /* Reserved/alignment to 8-byte
boundary. */
} __attribute__ ((__packed__));
/* Non-resident attributes. */
struct {
/* 16*/ VCN lowest_vcn; /* Lowest valid virtual cluster number
for this portion of the attribute value or
0 if this is the only extent (usually the
case). - Only when an attribute list is used
does lowest_vcn != 0 ever occur. */
/* 24*/ VCN highest_vcn; /* Highest valid vcn of this extent of
the attribute value. - Usually there is only one
portion, so this usually equals the attribute
value size in clusters minus 1. Can be -1 for
zero length files. Can be 0 for "single extent"
attributes. */
/* 32*/ u16 mapping_pairs_offset; /* Byte offset from the
beginning of the structure to the mapping pairs
array which contains the mappings between the
vcns and the logical cluster numbers (lcns).
When creating, place this at the end of this
record header aligned to 8-byte boundary. */
/* 34*/ u8 compression_unit; /* The compression unit expressed
as the log to the base 2 of the number of
clusters in a compression unit. 0 means not
compressed. (This effectively limits the
compression unit size to be a power of two
clusters.) WinNT4 only uses a value of 4. */
/* 35*/ u8 reserved1[5]; /* Align to 8-byte boundary. */
/* The sizes below are only used when lowest_vcn is zero, as otherwise it would
be difficult to keep them up-to-date.*/
/* 40*/ s64 allocated_size; /* Byte size of disk space
allocated to hold the attribute value. Always
is a multiple of the cluster size. When a file
is compressed, this field is a multiple of the
compression block size (2^compression_unit) and
it represents the logically allocated space
rather than the actual on disk usage. For this
use the compressed_size (see below). */
/* 48*/ s64 data_size; /* Byte size of the attribute
value. Can be larger than allocated_size if
attribute value is compressed or sparse. */
/* 56*/ s64 initialized_size; /* Byte size of initialized
portion of the attribute value. Usually equals
data_size. */
/* sizeof(uncompressed attr) = 64*/
/* 64*/ s64 compressed_size; /* Byte size of the attribute
value after compression. Only present when
compressed. Always is a multiple of the
cluster size. Represents the actual amount of
disk space being used on the disk. */
/* sizeof(compressed attr) = 72*/
} __attribute__ ((__packed__));
} __attribute__ ((__packed__));
} __attribute__ ((__packed__)) ATTR_RECORD;
typedef enum {
LCN_HOLE = -1, /* Keep this as highest value or die! */
LCN_RL_NOT_MAPPED = -2,
LCN_ENOENT = -3,
LCN_EINVAL = -4,
} LCN_SPECIAL_VALUES;
int ntfs_a = 0;
int ntfs_f = 0;
static inline void *ntfs_malloc_nofs(unsigned long size)
{
ntfs_a++;
return malloc(PAGE_SIZE);
}
static inline void ntfs_free(void *addr)
{
ntfs_f++;
free(addr);
}
#undef vsnprintf
int vsnprintf (char *s, size_t maxlen, const char *format, _G_va_list arg);
static char err_buf[1024];
#define ntfs_error(sb, f, a...) __ntfs_error(__FUNCTION__, sb, f, ##a)
void __ntfs_error(const char *function, const void *sb,
const char *fmt, ...)
{
va_list args;
int flen = 0;
if (function)
flen = strlen(function);
va_start(args, fmt);
vsnprintf(err_buf, sizeof(err_buf), fmt, args);
va_end(args);
printf("error: %s(): %s\n", flen ? function : "", err_buf);
}
void ntfs_debug_dump_runlist(const run_list *rl)
{
int i;
const char *lcn_str[5] = { "| |", "----", "!ENT", "EINV", "XXXX" };
if (!rl) {
printf(" Run list not present.\n");
return;
}
printf(" VCN LCN len\n");
for (i = 0; ; i++) {
LCN lcn = (rl + i)->lcn;
if (lcn < (LCN)0) {
int index = -lcn - 1;
if (index > -LCN_EINVAL - 1)
index = 4;
printf(" %8lld %s %8lld\n",
(rl + i)->vcn, lcn_str[index],
(rl + i)->length);
} else
printf(" %8lld %8lld %8lld\n",
(rl + i)->vcn, (rl + i)->lcn,
(rl + i)->length);
if (!(rl + i)->length)
break;
}
printf ("\n");
}
/**
* read_buffer
*/
int read_buffer (u8 *file, u8 *buf, int bufsize)
{
int fd;
fd = open (file, O_RDONLY);
if (fd < 0) {
printf ("open %s\n", file);
return 0;
}
memset (buf, 0, bufsize);
if (read (fd, buf, bufsize) < 0) {
printf ("read %s\n", file);
return 0;
}
close (fd);
return 1;
}
--- NEW FILE ---
#include "compat.c"
#define CONTIG 1
#define MULTI 0
/**
* config
*/
#if CONTIG
int fudge = 0;
#else
int fudge = 999;
#endif
/*
}
*/
/* Temporary helper functions -- might become macros */
[...991 lines suppressed...]
rl1 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf1, NULL);
if (IS_ERR (rl1))
return 1;
//rl2 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf2, NULL);
if (IS_ERR (rl2))
return 1;
//rl3 = decompress_mapping_pairs (&vol, (ATTR_RECORD*) buf3, NULL);
if (IS_ERR (rl3))
return 1;
printf ("success\n");
/*
}
*/
#endif
//printf ("%d,%d\n", ntfs_a, ntfs_f);
return 0;
}
|