update libntfs-3g to 1.0
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20301 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
SubDir HAIKU_TOP src add-ons kernel file_systems ntfs libntfs ;
|
||||
|
||||
SubDirCcFlags -Wall -Wno-multichar -DHAVE_CONFIG_H=1 -D_BEOS_=1 ;
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
|
||||
SubDirCcFlags -Wall -Wno-multichar -DHAVE_CONFIG_H=1 ;
|
||||
|
||||
StaticLibrary libntfs.a :
|
||||
attrib.c
|
||||
|
||||
@@ -4180,8 +4180,9 @@ retry:
|
||||
memmove((u8*)a + le16_to_cpu(a->name_offset) -
|
||||
8, (u8*)a + le16_to_cpu(a->name_offset),
|
||||
a->name_length * sizeof(ntfschar));
|
||||
a->name_offset = cpu_to_le16(le16_to_cpu(
|
||||
a->name_offset) - 8);
|
||||
if (le16_to_cpu(a->name_offset) >= 8)
|
||||
a->name_offset = cpu_to_le16(
|
||||
le16_to_cpu(a->name_offset) - 8);
|
||||
a->mapping_pairs_offset =
|
||||
cpu_to_le16(le16_to_cpu(
|
||||
a->mapping_pairs_offset) - 8);
|
||||
|
||||
@@ -64,25 +64,6 @@ BOOL ntfs_boot_sector_is_ntfs(NTFS_BOOT_SECTOR *b)
|
||||
|
||||
ntfs_log_debug("Beginning bootsector check.\n");
|
||||
|
||||
/* Calculate the checksum. Note, this is just a simple addition of
|
||||
all u32 values in the bootsector starting at the beginning and
|
||||
finishing at the offset of the checksum itself (i.e. not including
|
||||
the checksum...). */
|
||||
if ((void*)b < (void*)&b->checksum) {
|
||||
u32 *u = (u32 *)b;
|
||||
u32 *bi = (u32 *)(&b->checksum);
|
||||
|
||||
ntfs_log_debug("Calculating bootsector checksum.\n");
|
||||
|
||||
for (i = 0; u < bi; ++u)
|
||||
i += le32_to_cpup(u);
|
||||
|
||||
if (le32_to_cpu(b->checksum) && le32_to_cpu(b->checksum) != i) {
|
||||
ntfs_log_error("Bootsector checksum failed.\n");
|
||||
goto not_ntfs;
|
||||
}
|
||||
}
|
||||
|
||||
ntfs_log_debug("Checking OEMid, NTFS signature.\n");
|
||||
if (b->oem_id != cpu_to_le64(0x202020205346544eULL)) { /* "NTFS " */
|
||||
ntfs_log_error("NTFS signature is missing.\n");
|
||||
@@ -215,7 +196,8 @@ int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
|
||||
if (vol->dev->d_ops->seek(vol->dev,
|
||||
(sectors - 1) << vol->sector_size_bits,
|
||||
SEEK_SET) == -1) {
|
||||
ntfs_log_perror("Failed to read last sector (%lld)", sectors);
|
||||
ntfs_log_perror("Failed to read last sector (%lld)",
|
||||
(long long)sectors);
|
||||
ntfs_log_error("Perhaps the volume is a RAID/LDM but it wasn't "
|
||||
"setup yet, or the\nwrong device was used, "
|
||||
"or the partition table is incorrect.\n" );
|
||||
@@ -232,7 +214,8 @@ int ntfs_boot_sector_parse(ntfs_volume *vol, const NTFS_BOOT_SECTOR *bs)
|
||||
vol->mftmirr_lcn > vol->nr_clusters) {
|
||||
ntfs_log_error("$MFT LCN (%lld) or $MFTMirr LCN (%lld) is "
|
||||
"greater than the number of clusters (%lld).\n",
|
||||
vol->mft_lcn, vol->mftmirr_lcn, vol->nr_clusters);
|
||||
(long long)vol->mft_lcn, (long long)vol->mftmirr_lcn,
|
||||
(long long)vol->nr_clusters);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
//#ifdef WINDOWS
|
||||
#if defined(WINDOWS) || defined(__BEOS__) || defined (__HAIKU__)
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
@@ -69,5 +69,5 @@ int ffs(int x)
|
||||
}
|
||||
#endif /* HAVE_FFS */
|
||||
|
||||
//#endif /* WINDOWS */
|
||||
#endif /* defined(WINDOWS) || defined(__BEOS__) || defined (__HAIKU__) */
|
||||
|
||||
|
||||
@@ -409,7 +409,8 @@ s64 ntfs_cluster_read(const ntfs_volume *vol, const s64 lcn, const s64 count,
|
||||
if (vol->nr_clusters < lcn + count) {
|
||||
errno = ESPIPE;
|
||||
ntfs_log_perror("Trying to read outside of volume "
|
||||
"(%lld < %lld)", vol->nr_clusters, lcn + count);
|
||||
"(%lld < %lld)", (long long)vol->nr_clusters,
|
||||
(long long)lcn + count);
|
||||
return -1;
|
||||
}
|
||||
br = ntfs_pread(vol->dev, lcn << vol->cluster_size_bits,
|
||||
@@ -444,7 +445,8 @@ s64 ntfs_cluster_write(const ntfs_volume *vol, const s64 lcn,
|
||||
if (vol->nr_clusters < lcn + count) {
|
||||
errno = ESPIPE;
|
||||
ntfs_log_perror("Trying to write outside of volume "
|
||||
"(%lld < %lld)", vol->nr_clusters, lcn + count);
|
||||
"(%lld < %lld)", (long long)vol->nr_clusters,
|
||||
(long long)lcn + count);
|
||||
return -1;
|
||||
}
|
||||
if (!NVolReadOnly(vol))
|
||||
|
||||
@@ -259,7 +259,8 @@ descend_into_child_node:
|
||||
if (br != 1) {
|
||||
if (br != -1)
|
||||
errno = EIO;
|
||||
ntfs_log_perror("Failed to read vcn 0x%llx", vcn);
|
||||
ntfs_log_perror("Failed to read vcn 0x%llx",
|
||||
(unsigned long long)vcn);
|
||||
goto close_err_out;
|
||||
}
|
||||
|
||||
@@ -1047,10 +1048,7 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni,
|
||||
/* Allocate MFT record for new file. */
|
||||
ni = ntfs_mft_record_alloc(dir_ni->vol, NULL);
|
||||
if (!ni) {
|
||||
err = errno;
|
||||
ntfs_log_error("Could not allocate new MFT record: %s.\n",
|
||||
strerror(err));
|
||||
errno = err;
|
||||
ntfs_log_perror("Could not allocate new MFT record");
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
@@ -1158,12 +1156,10 @@ static ntfs_inode *__ntfs_create(ntfs_inode *dir_ni,
|
||||
memcpy(data->target, target,
|
||||
target_len * sizeof(ntfschar));
|
||||
break;
|
||||
#ifndef _BEOS_
|
||||
case S_IFSOCK:
|
||||
data = NULL;
|
||||
data_len = 1;
|
||||
break;
|
||||
#endif
|
||||
default: /* FIFO or regular file. */
|
||||
data = NULL;
|
||||
data_len = 0;
|
||||
@@ -1258,7 +1254,8 @@ err_out:
|
||||
ntfs_inode *ntfs_create(ntfs_inode *dir_ni, ntfschar *name, u8 name_len,
|
||||
dev_t type)
|
||||
{
|
||||
if (type != S_IFREG && type != S_IFDIR && type != S_IFIFO /*&& type != S_IFSOCK*/) {
|
||||
if (type != S_IFREG && type != S_IFDIR && type != S_IFIFO &&
|
||||
type != S_IFSOCK) {
|
||||
ntfs_log_error("Invalid arguments.\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1302,7 +1299,7 @@ int ntfs_check_empty_dir(ntfs_inode *ni)
|
||||
}
|
||||
|
||||
/* Non-empty directory? */
|
||||
if ((na->data_size != sizeof(INDEX_ROOT) + sizeof(INDEX_ENTRY_HEADER))){
|
||||
if ((na->data_size != sizeof(INDEX_ROOT) + sizeof(INDEX_ENTRY_HEADER))) {
|
||||
/* Both ENOTEMPTY and EEXIST are ok. We use the more common. */
|
||||
errno = EEXIST;
|
||||
ntfs_log_debug("Directory is not empty\n");
|
||||
@@ -1419,7 +1416,7 @@ search:
|
||||
|
||||
if (ntfs_names_are_equal(fn->file_name, fn->file_name_length,
|
||||
name, name_len, case_sensitive,
|
||||
ni->vol->upcase, ni->vol->upcase_len)){
|
||||
ni->vol->upcase, ni->vol->upcase_len)) {
|
||||
|
||||
if (fn->file_name_type == FILE_NAME_WIN32) {
|
||||
looking_for_dos_name = TRUE;
|
||||
@@ -1532,7 +1529,7 @@ out:
|
||||
ntfs_inode_close(ni);
|
||||
if (err) {
|
||||
errno = err;
|
||||
ntfs_log_perror("Could not delete file");
|
||||
ntfs_log_debug("Could not delete file: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
ntfs_log_trace("Done.\n");
|
||||
|
||||
@@ -32,6 +32,14 @@
|
||||
#define MAX_PATH 1024
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We do not have S_IFSOCK under BeOS/Haiku
|
||||
*/
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
#ifndef S_IFSOCK
|
||||
#define S_IFSOCK 0140000
|
||||
#endif
|
||||
#endif
|
||||
/*
|
||||
* We do not have these under DJGPP, so define our version that do not conflict
|
||||
* with other S_IFs defined under DJGPP.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* endians.h - Definitions related to handling of byte ordering. Part of the
|
||||
* Linux-NTFS project.
|
||||
* endians.h - Definitions related to handling of byte ordering.
|
||||
* Originated from the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2000-2005 Anton Altaparmakov
|
||||
*
|
||||
@@ -15,7 +15,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program (in the main directory of the Linux-NTFS
|
||||
* along with this program (in the main directory of the NTFS-3G
|
||||
* distribution in the file COPYING); if not, write to the Free Software
|
||||
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
@@ -48,6 +48,9 @@
|
||||
#ifdef HAVE_SYS_BYTEORDER_H
|
||||
#include <sys/byteorder.h>
|
||||
#endif
|
||||
#ifdef HAVE_BYTEORDER_H
|
||||
#include <byteorder.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
@@ -88,7 +88,8 @@ static int ntfs_ib_write(ntfs_index_context *icx, VCN vcn, void *buf)
|
||||
1, icx->block_size, buf);
|
||||
if (ret != 1) {
|
||||
ntfs_log_perror("Failed to write index block %lld of inode "
|
||||
"%llu", vcn, icx->ni->mft_no);
|
||||
"%llu", (long long)vcn,
|
||||
(unsigned long long)icx->ni->mft_no);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -397,7 +398,8 @@ static int ntfs_ia_check(ntfs_index_context *icx, INDEX_BLOCK *ib, VCN vcn)
|
||||
if (!ntfs_is_indx_record(ib->magic)) {
|
||||
|
||||
ntfs_log_error("Corrupt index block signature: vcn %lld inode "
|
||||
"%llu\n", (long long)vcn, icx->ni->mft_no);
|
||||
"%llu\n", (long long)vcn,
|
||||
(unsigned long long)icx->ni->mft_no);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -405,8 +407,9 @@ static int ntfs_ia_check(ntfs_index_context *icx, INDEX_BLOCK *ib, VCN vcn)
|
||||
|
||||
ntfs_log_error("Corrupt index block: VCN (%lld) is different "
|
||||
"from expected VCN (%lld) in inode %llu\n",
|
||||
(long long) sle64_to_cpu(ib->index_block_vcn),
|
||||
(long long)vcn, icx->ni->mft_no);
|
||||
(long long)sle64_to_cpu(ib->index_block_vcn),
|
||||
(long long)vcn,
|
||||
(unsigned long long)icx->ni->mft_no);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -415,7 +418,8 @@ static int ntfs_ia_check(ntfs_index_context *icx, INDEX_BLOCK *ib, VCN vcn)
|
||||
ntfs_log_error("Corrupt index block : VCN (%lld) of inode %llu "
|
||||
"has a size (%u) differing from the index "
|
||||
"specified size (%u)\n", (long long)vcn,
|
||||
icx->ni->mft_no, ib_size, icx->block_size);
|
||||
(unsigned long long)icx->ni->mft_no, ib_size,
|
||||
icx->block_size);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -489,7 +493,8 @@ static int ntfs_ie_lookup(const void *key, const int key_len,
|
||||
(u8 *)ie + le16_to_cpu(ie->length) > index_end) {
|
||||
errno = ERANGE;
|
||||
ntfs_log_error("Index entry out of bounds in inode "
|
||||
"%llu.\n", icx->ni->mft_no);
|
||||
"%llu.\n",
|
||||
(unsigned long long)icx->ni->mft_no);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
/*
|
||||
@@ -543,7 +548,8 @@ static int ntfs_ie_lookup(const void *key, const int key_len,
|
||||
*vcn = ntfs_ie_get_vcn(ie);
|
||||
if (*vcn < 0) {
|
||||
errno = EINVAL;
|
||||
ntfs_log_perror("Negative vcn in inode %llu\n", icx->ni->mft_no);
|
||||
ntfs_log_perror("Negative vcn in inode %llu\n",
|
||||
(unsigned long long)icx->ni->mft_no);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@@ -560,7 +566,7 @@ static ntfs_attr *ntfs_ia_open(ntfs_index_context *icx, ntfs_inode *ni)
|
||||
na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, icx->name, icx->name_len);
|
||||
if (!na) {
|
||||
ntfs_log_perror("Failed to open index allocation of inode "
|
||||
"%llu", ni->mft_no);
|
||||
"%llu", (unsigned long long)ni->mft_no);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -581,7 +587,7 @@ static int ntfs_ib_read(ntfs_index_context *icx, VCN vcn, INDEX_BLOCK *dst)
|
||||
ntfs_log_perror("Failed to read index block");
|
||||
else
|
||||
ntfs_log_error("Failed to read full index block at "
|
||||
"%lld\n", pos);
|
||||
"%lld\n", (long long)pos);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -755,7 +761,8 @@ descend_into_child_node:
|
||||
|
||||
if ((ib->index.ih_flags & NODE_MASK) == LEAF_NODE) {
|
||||
ntfs_log_error("Index entry with child node found in a leaf "
|
||||
"node in inode 0x%llx.\n", ni->mft_no);
|
||||
"node in inode 0x%llx.\n",
|
||||
(unsigned long long)ni->mft_no);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
|
||||
@@ -1099,12 +1099,11 @@ void ntfs_inode_update_atime(ntfs_inode *ni)
|
||||
*/
|
||||
void ntfs_inode_update_time(ntfs_inode *ni)
|
||||
{
|
||||
if (!NVolReadOnly(ni->vol) && !NVolNoATime(ni->vol) && (ni->mft_no >=
|
||||
FILE_first_user || ni->mft_no == FILE_root)) {
|
||||
if (!NVolReadOnly(ni->vol) &&
|
||||
(ni->mft_no >= FILE_first_user || ni->mft_no == FILE_root)) {
|
||||
time_t now;
|
||||
|
||||
now = time(NULL);
|
||||
ni->last_access_time = now;
|
||||
ni->last_data_change_time = now;
|
||||
ni->last_mft_change_time = now;
|
||||
NInoFileNameSetDirty(ni);
|
||||
|
||||
@@ -49,10 +49,10 @@
|
||||
|
||||
#define NTFS_LCNALLOC_SKIP 4096
|
||||
|
||||
void ntfs_cluster_set_zone_pos(u8 zone, LCN zone_start, LCN zone_end,
|
||||
LCN *zone_pos, LCN tc, LCN bmp_initial_pos)
|
||||
static void ntfs_cluster_set_zone_pos(LCN zone_start, LCN zone_end,
|
||||
LCN *zone_pos, LCN tc, LCN bmp_initial_pos)
|
||||
{
|
||||
ntfs_log_trace("Before: zone %d = %lld\n", zone, (long long)*zone_pos);
|
||||
ntfs_log_trace("Before: zone_pos: %lld\n", (long long)*zone_pos);
|
||||
|
||||
if (tc >= zone_end) {
|
||||
*zone_pos = zone_start;
|
||||
@@ -63,29 +63,29 @@ void ntfs_cluster_set_zone_pos(u8 zone, LCN zone_start, LCN zone_end,
|
||||
tc >= zone_start)
|
||||
*zone_pos = tc;
|
||||
|
||||
ntfs_log_trace("After: zone %d = %lld\n", zone, (long long)*zone_pos);
|
||||
ntfs_log_trace("After: zone_pos: %lld\n", (long long)*zone_pos);
|
||||
}
|
||||
|
||||
int ntfs_cluster_update_zone_pos(ntfs_volume *vol, u8 zone, LCN tc,
|
||||
LCN bmp_initial_pos)
|
||||
static int ntfs_cluster_update_zone_pos(ntfs_volume *vol, u8 zone, LCN tc,
|
||||
LCN bmp_initial_pos)
|
||||
{
|
||||
ntfs_log_trace("tc = %lld, zone = %d\n", (long long)tc, zone);
|
||||
|
||||
switch (zone) {
|
||||
case 1:
|
||||
ntfs_cluster_set_zone_pos(zone, vol->mft_lcn,
|
||||
ntfs_cluster_set_zone_pos(vol->mft_lcn,
|
||||
vol->mft_zone_end,
|
||||
&vol->mft_zone_pos,
|
||||
tc, bmp_initial_pos);
|
||||
break;
|
||||
case 2:
|
||||
ntfs_cluster_set_zone_pos(zone, vol->mft_zone_end,
|
||||
ntfs_cluster_set_zone_pos(vol->mft_zone_end,
|
||||
vol->nr_clusters,
|
||||
&vol->data1_zone_pos,
|
||||
tc, bmp_initial_pos);
|
||||
break;
|
||||
case 4:
|
||||
ntfs_cluster_set_zone_pos(zone, 0,
|
||||
ntfs_cluster_set_zone_pos(0,
|
||||
vol->mft_zone_start,
|
||||
&vol->data2_zone_pos,
|
||||
tc, bmp_initial_pos);
|
||||
|
||||
@@ -655,19 +655,16 @@ BOOL ntfs_is_logfile_clean(ntfs_attr *log_na, RESTART_PAGE_HEADER *rp)
|
||||
ntfs_log_trace("Entering.\n");
|
||||
/* An empty $LogFile must have been clean before it got emptied. */
|
||||
if (NVolLogFileEmpty(log_na->ni->vol)) {
|
||||
ntfs_log_trace("Done. ($LogFile is empty.)\n");
|
||||
ntfs_log_trace("$LogFile is empty\n");
|
||||
return TRUE;
|
||||
}
|
||||
if (!rp) {
|
||||
ntfs_log_error("Restart page header is NULL.\n");
|
||||
ntfs_log_error("Restart page header is NULL\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!ntfs_is_rstr_record(rp->magic) &&
|
||||
!ntfs_is_chkd_record(rp->magic)) {
|
||||
ntfs_log_error("Restart page buffer is invalid. This is "
|
||||
"probably a bug in that the $LogFile should "
|
||||
"have been consistency checked before calling "
|
||||
"this function.\n");
|
||||
ntfs_log_error("Restart page buffer is invalid\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -679,11 +676,13 @@ BOOL ntfs_is_logfile_clean(ntfs_attr *log_na, RESTART_PAGE_HEADER *rp)
|
||||
*/
|
||||
if (ra->client_in_use_list != LOGFILE_NO_CLIENT &&
|
||||
!(ra->flags & RESTART_VOLUME_IS_CLEAN)) {
|
||||
ntfs_log_debug("Done. $LogFile indicates a dirty shutdown.\n");
|
||||
ntfs_log_error("$LogFile indicates unclean shutdown (%d, %d)\n",
|
||||
le16_to_cpu(ra->client_in_use_list),
|
||||
le16_to_cpu(ra->flags));
|
||||
return FALSE;
|
||||
}
|
||||
/* $LogFile indicates a clean shutdown. */
|
||||
ntfs_log_trace("Done. $LogFile indicates a clean shutdown.\n");
|
||||
ntfs_log_trace("$LogFile indicates a clean shutdown\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -195,9 +195,9 @@ u32 ntfs_log_clear_flags(u32 flags)
|
||||
*/
|
||||
static FILE * ntfs_log_get_stream(u32 level)
|
||||
{
|
||||
#ifdef _BEOS_
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
return NULL;
|
||||
#else
|
||||
#elif
|
||||
FILE *stream;
|
||||
|
||||
switch (level) {
|
||||
@@ -220,7 +220,7 @@ static FILE * ntfs_log_get_stream(u32 level)
|
||||
}
|
||||
|
||||
return stream;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -415,9 +415,9 @@ int ntfs_log_handler_syslog(const char *function __attribute__((unused)),
|
||||
int ntfs_log_handler_fprintf(const char *function, const char *file,
|
||||
int line, u32 level, void *data, const char *format, va_list args)
|
||||
{
|
||||
#ifdef _BEOS_
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
return 0;
|
||||
#else
|
||||
#elif
|
||||
int ret = 0;
|
||||
int olderr = errno;
|
||||
FILE *stream;
|
||||
@@ -487,7 +487,7 @@ int ntfs_log_handler_fprintf(const char *function, const char *file,
|
||||
fflush(stream);
|
||||
errno = olderr;
|
||||
return ret;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -536,13 +536,13 @@ int ntfs_log_handler_null(const char *function __attribute__((unused)), const ch
|
||||
int ntfs_log_handler_stdout(const char *function, const char *file,
|
||||
int line, u32 level, void *data, const char *format, va_list args)
|
||||
{
|
||||
#ifndef _BEOS_
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
return 0;
|
||||
#elif
|
||||
if (!data)
|
||||
data = stdout;
|
||||
|
||||
return ntfs_log_handler_fprintf(function, file, line, level, data, format, args);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -571,10 +571,14 @@ int ntfs_log_handler_stdout(const char *function, const char *file,
|
||||
int ntfs_log_handler_outerr(const char *function, const char *file,
|
||||
int line, u32 level, void *data, const char *format, va_list args)
|
||||
{
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
return 0;
|
||||
#elif
|
||||
if (!data)
|
||||
data = ntfs_log_get_stream(level);
|
||||
|
||||
return ntfs_log_handler_fprintf(function, file, line, level, data, format, args);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -601,10 +605,14 @@ int ntfs_log_handler_outerr(const char *function, const char *file,
|
||||
int ntfs_log_handler_stderr(const char *function, const char *file,
|
||||
int line, u32 level, void *data, const char *format, va_list args)
|
||||
{
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
return 0;
|
||||
#elif
|
||||
if (!data)
|
||||
data = stderr;
|
||||
|
||||
return ntfs_log_handler_fprintf(function, file, line, level, data, format, args);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -92,8 +92,8 @@ int ntfs_mft_records_read(const ntfs_volume *vol, const MFT_REF mref,
|
||||
vol->mft_record_size_bits) {
|
||||
errno = ESPIPE;
|
||||
ntfs_log_perror("Trying to read non-allocated mft records "
|
||||
"(%lld > %lld)", m + count,
|
||||
vol->mft_na->initialized_size >>
|
||||
"(%lld > %lld)", (long long)m + count,
|
||||
(long long)vol->mft_na->initialized_size >>
|
||||
vol->mft_record_size_bits);
|
||||
return -1;
|
||||
}
|
||||
@@ -155,8 +155,8 @@ int ntfs_mft_records_write(const ntfs_volume *vol, const MFT_REF mref,
|
||||
vol->mft_record_size_bits) {
|
||||
errno = ESPIPE;
|
||||
ntfs_log_perror("Trying to write non-allocated mft records "
|
||||
"(%lld > %lld)", m + count,
|
||||
vol->mft_na->initialized_size >>
|
||||
"(%lld > %lld)", (long long)m + count,
|
||||
(long long)vol->mft_na->initialized_size >>
|
||||
vol->mft_record_size_bits);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
@@ -34,3 +38,17 @@ void *ntfs_malloc(size_t size)
|
||||
return p;
|
||||
}
|
||||
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
int ntfs_snprintf(char *buff, size_t size, const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
char buffer[BUFSIZ];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
memset(buffer,0,BUFSIZ);
|
||||
ret = sprintf(buffer, format, args);
|
||||
va_end(args);
|
||||
strncpy(buff,buffer,size);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@@ -4,5 +4,8 @@
|
||||
void *ntfs_calloc(size_t size);
|
||||
void *ntfs_malloc(size_t size);
|
||||
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
#define snprintf ntfs_snprintf
|
||||
#endif /* defined(__BEOS__) || defined(__HAIKU__) */
|
||||
#endif /* _NTFS_MISC_H_ */
|
||||
|
||||
|
||||
@@ -1040,7 +1040,8 @@ s64 ntfs_rl_pread(const ntfs_volume *vol, const runlist_element *rl,
|
||||
if (!vol || !rl || pos < 0 || count < 0) {
|
||||
errno = EINVAL;
|
||||
ntfs_log_perror("Failed to read runlist [vol: %p rl: %p "
|
||||
"pos: %lld count: %lld]", vol, rl, pos, count);
|
||||
"pos: %lld count: %lld]", vol, rl,
|
||||
(long long)pos, (long long)count);
|
||||
return -1;
|
||||
}
|
||||
if (!count)
|
||||
@@ -1127,7 +1128,8 @@ s64 ntfs_rl_pwrite(const ntfs_volume *vol, const runlist_element *rl,
|
||||
if (!vol || !rl || pos < 0 || count < 0) {
|
||||
errno = EINVAL;
|
||||
ntfs_log_perror("Failed to write runlist [vol: %p rl: %p "
|
||||
"pos: %lld count: %lld]", vol, rl, pos, count);
|
||||
"pos: %lld count: %lld]", vol, rl,
|
||||
(long long)pos, (long long)count);
|
||||
goto errno_set;
|
||||
}
|
||||
if (!count)
|
||||
|
||||
@@ -44,21 +44,6 @@
|
||||
#include "security.h"
|
||||
#include "misc.h"
|
||||
|
||||
#ifdef _BEOS_
|
||||
int be_snprintf(char *buff, size_t size, const char *format, ...)
|
||||
{
|
||||
int ret;
|
||||
char temp[1024];
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
ret = sprintf(temp, format, args);
|
||||
va_end(args);
|
||||
strncpy(buff,temp,size);
|
||||
return ret;
|
||||
}
|
||||
#define snprintf be_snprintf
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The zero GUID.
|
||||
*/
|
||||
|
||||
@@ -373,27 +373,28 @@ int ntfs_file_values_compare(const FILE_NAME_ATTR *file_name_attr1,
|
||||
err_val, ic, upcase, upcase_len);
|
||||
}
|
||||
|
||||
#ifdef _BEOS_
|
||||
|
||||
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
/* Encode a single wide character into a sequence of utf8 bytes.
|
||||
* Returns the number of bytes consumed, or 0 on error.
|
||||
*/
|
||||
static int
|
||||
to_utf8(wchar_t c,unsigned char* buf)
|
||||
ntfs_wc_to_utf8(wchar_t c,unsigned char* buf)
|
||||
{
|
||||
if(c==0)
|
||||
return 0; /* No support for embedded 0 runes */
|
||||
if(c<0x80){
|
||||
if(c<0x80) {
|
||||
if(buf)buf[0]=(unsigned char)c;
|
||||
return 1;
|
||||
}
|
||||
if(c<0x800){
|
||||
if(buf){
|
||||
if(c<0x800) {
|
||||
if(buf) {
|
||||
buf[0] = 0xc0 | (c>>6);
|
||||
buf[1] = 0x80 | (c & 0x3f);
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
if(c<0x10000){
|
||||
if(buf){
|
||||
if(c<0x10000) {
|
||||
if(buf) {
|
||||
buf[0] = 0xe0 | (c>>12);
|
||||
buf[1] = 0x80 | ((c>>6) & 0x3f);
|
||||
buf[2] = 0x80 | (c & 0x3f);
|
||||
@@ -410,30 +411,30 @@ to_utf8(wchar_t c,unsigned char* buf)
|
||||
* Returns the number of bytes consumed, or 0 on error.
|
||||
*/
|
||||
static int
|
||||
from_utf8(const unsigned char* str,wchar_t *c)
|
||||
ntfs_wc_from_utf8(const unsigned char* str,wchar_t *c)
|
||||
{
|
||||
int l=0,i;
|
||||
|
||||
if(*str<0x80){
|
||||
if(*str<0x80) {
|
||||
*c = *str;
|
||||
return 1;
|
||||
}
|
||||
if(*str<0xc0) /* lead byte must not be 10xxxxxx */
|
||||
return 0; /* is c0 a possible lead byte? */
|
||||
if(*str<0xe0){ /* 110xxxxx */
|
||||
if(*str<0xe0) { /* 110xxxxx */
|
||||
*c = *str & 0x1f;
|
||||
l=2;
|
||||
}else if(*str<0xf0){ /* 1110xxxx */
|
||||
} else if(*str<0xf0) { /* 1110xxxx */
|
||||
*c = *str & 0xf;
|
||||
l=3;
|
||||
}else if(*str<0xf8){ /* 11110xxx */
|
||||
} else if(*str<0xf8) { /* 11110xxx */
|
||||
*c = *str & 7;
|
||||
l=4;
|
||||
}else /* We don't support characters above 0xFFFF in NTFS */
|
||||
} else /* We don't support characters above 0xFFFF in NTFS */
|
||||
return 0;
|
||||
|
||||
|
||||
for(i=1;i<l;i++){
|
||||
for(i=1;i<l;i++) {
|
||||
/* all other bytes must be 10xxxxxx */
|
||||
if((str[i] & 0xc0) != 0x80)
|
||||
return 0;
|
||||
@@ -449,15 +450,15 @@ from_utf8(const unsigned char* str,wchar_t *c)
|
||||
* The caller has to free the result string.
|
||||
* There is no support for UTF-16, yet
|
||||
*/
|
||||
static int ntfs_dupuni2utf8(wchar_t* in, int in_len,char **out,int *out_len)
|
||||
static inline int ntfs_dupuni2utf8(wchar_t* in, int in_len,char **out,int *out_len)
|
||||
{
|
||||
int i,tmp;
|
||||
int len8;
|
||||
unsigned char *result;
|
||||
|
||||
/* count the length of the resulting UTF-8 */
|
||||
for(i=len8=0;i<in_len;i++){
|
||||
tmp=to_utf8(le16_to_cpu( *(in+i) ),0);
|
||||
for(i=len8=0;i<in_len;i++) {
|
||||
tmp=ntfs_wc_to_utf8(le16_to_cpu( *(in+i) ),0);
|
||||
if(!tmp)
|
||||
/* invalid character */
|
||||
return EILSEQ;
|
||||
@@ -470,22 +471,22 @@ static int ntfs_dupuni2utf8(wchar_t* in, int in_len,char **out,int *out_len)
|
||||
result[len8]='\0';
|
||||
*out_len=len8;
|
||||
for(i=len8=0;i<in_len;i++)
|
||||
len8+=to_utf8(le16_to_cpu( *(in+i) ),result+len8);
|
||||
len8+=ntfs_wc_to_utf8(le16_to_cpu( *(in+i) ),result+len8);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Converts an UTF-8 sequence to a wide string. Same conventions as the
|
||||
* previous function
|
||||
*/
|
||||
static int ntfs_duputf82uni(unsigned char* in, int in_len,wchar_t** out,int *out_len)
|
||||
static inline int ntfs_duputf82uni(unsigned char* in, int in_len,wchar_t** out,int *out_len)
|
||||
{
|
||||
int i,tmp;
|
||||
int len16;
|
||||
|
||||
wchar_t* result;
|
||||
wchar_t wtmp;
|
||||
for(i=len16=0;i<in_len;i+=tmp,len16++){
|
||||
tmp=from_utf8(in+i,&wtmp);
|
||||
for(i=len16=0;i<in_len;i+=tmp,len16++) {
|
||||
tmp=ntfs_wc_from_utf8(in+i,&wtmp);
|
||||
if(!tmp)
|
||||
return EILSEQ;
|
||||
}
|
||||
@@ -496,7 +497,7 @@ static int ntfs_duputf82uni(unsigned char* in, int in_len,wchar_t** out,int *out
|
||||
*out_len=len16;
|
||||
for(i=len16=0;i<in_len;i+=tmp,len16++)
|
||||
{
|
||||
tmp=from_utf8(in+i, &wtmp);
|
||||
tmp=ntfs_wc_from_utf8(in+i, &wtmp);
|
||||
*(result+len16) = cpu_to_le16(wtmp);
|
||||
}
|
||||
return 0;
|
||||
@@ -531,7 +532,7 @@ static int ntfs_duputf82uni(unsigned char* in, int in_len,wchar_t** out,int *out
|
||||
int ntfs_ucstombs(const ntfschar *ins, const int ins_len, char **outs, int outs_len)
|
||||
{
|
||||
int out_len = outs_len;
|
||||
if(ntfs_dupuni2utf8(ins,ins_len,outs,&out_len)==0)
|
||||
if(ntfs_dupuni2utf8((wchar_t*)ins,ins_len,outs,&out_len)==0)
|
||||
return out_len;
|
||||
else
|
||||
return EINVAL;
|
||||
@@ -565,7 +566,7 @@ int ntfs_mbstoucs(const char *ins, ntfschar **outs, int outs_len)
|
||||
{
|
||||
int in_len = strlen(ins);
|
||||
int out_len = outs_len;
|
||||
if(ntfs_duputf82uni(ins,in_len,outs,&out_len)==0)
|
||||
if(ntfs_duputf82uni((unsigned char*)ins,in_len,outs,&out_len)==0)
|
||||
return out_len;
|
||||
else
|
||||
return EILSEQ;
|
||||
@@ -838,7 +839,7 @@ err_out:
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // defined(__BEOS__) || defined(__HAIKU__)
|
||||
|
||||
/**
|
||||
* ntfs_upcase_table_build - build the default upcase table for NTFS
|
||||
|
||||
@@ -112,7 +112,8 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags)
|
||||
if ((flags & O_RDWR) != O_RDWR)
|
||||
NDevSetReadOnly(dev);
|
||||
|
||||
#ifndef _BEOS_
|
||||
/* locking not implemented in BeOS */
|
||||
#if !defined(__BEOS__) && !defined(__HAIKU__)
|
||||
memset(&flk, 0, sizeof(flk));
|
||||
if (NDevReadOnly(dev))
|
||||
flk.l_type = F_RDLCK;
|
||||
@@ -128,8 +129,7 @@ static int ntfs_device_unix_io_open(struct ntfs_device *dev, int flags)
|
||||
ntfs_log_perror("Failed to close '%s'", dev->d_name);
|
||||
goto err_out;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
NDevSetOpen(dev);
|
||||
return 0;
|
||||
err_out:
|
||||
@@ -157,8 +157,10 @@ static int ntfs_device_unix_io_close(struct ntfs_device *dev)
|
||||
}
|
||||
if (NDevDirty(dev))
|
||||
fsync(DEV_FD(dev));
|
||||
/* Release exclusive (mandatory) lock on the whole device. */
|
||||
#ifndef _BEOS_
|
||||
|
||||
/* locking not implemented in BeOS */
|
||||
#if !defined(__BEOS__) && !defined(__HAIKU__)
|
||||
/* Release exclusive (mandatory) lock on the whole device. */
|
||||
memset(&flk, 0, sizeof(flk));
|
||||
flk.l_type = F_UNLCK;
|
||||
flk.l_whence = SEEK_SET;
|
||||
@@ -243,7 +245,7 @@ static s64 ntfs_device_unix_io_write(struct ntfs_device *dev, const void *buf,
|
||||
static s64 ntfs_device_unix_io_pread(struct ntfs_device *dev, void *buf,
|
||||
s64 count, s64 offset)
|
||||
{
|
||||
#ifdef _BEOS_
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
return read_pos(DEV_FD(dev), offset, buf,count);
|
||||
#else
|
||||
return pread(DEV_FD(dev), buf, count, offset);
|
||||
@@ -269,11 +271,11 @@ static s64 ntfs_device_unix_io_pwrite(struct ntfs_device *dev, const void *buf,
|
||||
return -1;
|
||||
}
|
||||
NDevSetDirty(dev);
|
||||
#ifdef _BEOS_
|
||||
#if defined(__BEOS__) || defined(__HAIKU__)
|
||||
return write_pos(DEV_FD(dev), offset, buf,count);
|
||||
#else
|
||||
return pwrite(DEV_FD(dev), buf, count, offset);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -203,7 +203,8 @@ static int ntfs_mft_load(ntfs_volume *vol)
|
||||
NInoSetAttrList(vol->mft_ni);
|
||||
l = ntfs_get_attribute_value_length(ctx->attr);
|
||||
if (l <= 0 || l > 0x40000) {
|
||||
ntfs_log_error("$MFT/$ATTR_LIST invalid length (%lld).\n", l);
|
||||
ntfs_log_error("$MFT/$ATTR_LIST invalid length (%lld).\n",
|
||||
(long long)l);
|
||||
goto io_error_exit;
|
||||
}
|
||||
vol->mft_ni->attr_list_size = l;
|
||||
@@ -218,7 +219,8 @@ static int ntfs_mft_load(ntfs_volume *vol)
|
||||
}
|
||||
if (l != vol->mft_ni->attr_list_size) {
|
||||
ntfs_log_error("Partial read of $MFT/$ATTR_LIST (%lld != "
|
||||
"%u).\n", l, vol->mft_ni->attr_list_size);
|
||||
"%u).\n", (long long)l,
|
||||
vol->mft_ni->attr_list_size);
|
||||
goto io_error_exit;
|
||||
}
|
||||
|
||||
@@ -774,7 +776,8 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags)
|
||||
ntfs_log_perror("Failed to read $MFT");
|
||||
else {
|
||||
ntfs_log_error("Failed to read $MFT, unexpected length "
|
||||
"(%lld != %d).\n", l, vol->mftmirr_size);
|
||||
"(%lld != %d).\n", (long long)l,
|
||||
vol->mftmirr_size);
|
||||
errno = EIO;
|
||||
}
|
||||
goto error_exit;
|
||||
@@ -790,7 +793,8 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags)
|
||||
else {
|
||||
ntfs_log_error("Failed to read $MFTMirr "
|
||||
"unexpected length (%d != %lld)."
|
||||
"\n", vol->mftmirr_size, l);
|
||||
"\n", vol->mftmirr_size,
|
||||
(long long)l);
|
||||
errno = EIO;
|
||||
}
|
||||
goto error_exit;
|
||||
@@ -917,7 +921,8 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags)
|
||||
if (l != na->data_size) {
|
||||
ntfs_log_debug(FAILED);
|
||||
ntfs_log_error("Failed to read $UpCase, unexpected length "
|
||||
"(%lld != %lld).\n", l, na->data_size);
|
||||
"(%lld != %lld).\n", (long long)l,
|
||||
(long long)na->data_size);
|
||||
errno = EIO;
|
||||
goto error_exit;
|
||||
}
|
||||
@@ -1076,7 +1081,8 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags)
|
||||
if (l != na->data_size) {
|
||||
ntfs_log_debug(FAILED);
|
||||
ntfs_log_error("Failed to read $AttrDef, unexpected length "
|
||||
"(%lld != %lld).\n", l, na->data_size);
|
||||
"(%lld != %lld).\n", (long long)l,
|
||||
(long long)na->data_size);
|
||||
errno = EIO;
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define MS_EXCLUSIVE 0x08000000
|
||||
|
||||
/* Forward declaration */
|
||||
typedef struct _ntfs_volume ntfs_volume;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user