Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv6438/libntfs
Modified Files:
attrib.c disk_io.c mft.c ntfs_rec.c volume.c
Log Message:
Header file reorganisation so that it compiles.
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -U2 -r1.11 -r1.12
--- attrib.c 2001/04/08 03:02:55 1.11
+++ attrib.c 2001/04/11 11:49:16 1.12
@@ -29,10 +29,10 @@
#include <stdlib.h>
-#include "volume.h"
#include "attrib.h"
-#include "mft.h"
+#include "layout.h"
+#include "types.h"
+#include "unistr.h"
#include "endians.h"
#include "disk_io.h"
-#include "unistr.h"
#include "support.h"
Index: disk_io.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/disk_io.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -U2 -r1.10 -r1.11
--- disk_io.c 2001/04/08 03:02:55 1.10
+++ disk_io.c 2001/04/11 11:49:16 1.11
@@ -29,8 +29,7 @@
#include <stdio.h>
-#include "ntfs_rec.h"
-#include "attrib.h"
-#include "bitmap.h"
-#include "volume.h"
+#include "layout.h"
+#include "types.h"
+#include "disk_io.h"
__u64 ntfs_pwrite(int fd, const void *b, __u64 count, const __u64 pos)
@@ -280,5 +279,5 @@
*/
int get_mft_records(const ntfs_volume *vol, MFT_RECORD *mrec,
- const MFT_REFERENCE *mref, const int count)
+ const MFT_REF *mref, const int count)
{
__u64 br, ofs;
@@ -290,5 +289,5 @@
if (!vol->fd)
return -EBADF;
- m = *(__u64*)mref & MFT_REFERENCE_MASK_CPU;
+ m = MREF(*mref);
if (vol->number_of_mft_records < m + count)
return -ESPIPE;
@@ -349,5 +348,5 @@
*/
__inline__ int get_mft_record(const ntfs_volume *vol, MFT_RECORD *mrec,
- const MFT_REFERENCE *mref)
+ const MFT_REF *mref)
{
return get_mft_records(vol, mrec, mref, 1);
@@ -367,5 +366,5 @@
*
* The read mft record is checked for having the magic FILE, for being in use,
- * and for having a matching sequence number (if @mref->sequence_number != 0).
+ * and for having a matching sequence number (if MSEQNO(*@mref) != 0).
* If either of these fails, return -EIO.
*
@@ -374,5 +373,5 @@
* Note: Caller has to free *@mrec when finished.
*/
-int read_file_record(const ntfs_volume *vol, const MFT_REFERENCE *mref,
+int read_file_record(const ntfs_volume *vol, const MFT_REF *mref,
MFT_RECORD **mrec, ATTR_RECORD **attr)
{
@@ -393,6 +392,5 @@
if (!is_file_record(m->magic))
goto file_corrupt;
- if (mref->sequence_number &&
- mref->sequence_number != le16_to_cpu(m->sequence_number))
+ if (MSEQNO(mref) && MSEQNO(mref) != le16_to_cpu(m->sequence_number))
goto file_corrupt;
if (!(m->flags & MFT_RECORD_IN_USE))
@@ -415,5 +413,5 @@
}
-int put_mft_record(ntfs_volume *vol, const __u8 *buf, const MFT_REFERENCE *mref)
+int put_mft_record(ntfs_volume *vol, const __u8 *buf, const MFT_REF *mref)
{
__u64 bw, m;
@@ -424,5 +422,5 @@
if (!vol->fd)
return -EBADF;
- m = *(__u64*)mref & MFT_REFERENCE_MASK_CPU;
+ m = MREF(*mref);
if (vol->number_of_mft_records <= m)
return -ESPIPE;
Index: mft.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/mft.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -U2 -r1.7 -r1.8
--- mft.c 2001/04/10 23:37:19 1.7
+++ mft.c 2001/04/11 11:49:16 1.8
@@ -23,9 +23,14 @@
#include <linux/types.h>
-#include <linux/list.h>
#include <linux/errno.h>
+#include <linux/bitops.h>
+#include "list.h"
#include "mft.h"
+#include "layout.h"
+#include "types.h"
#include "endians.h"
+#include "disk_io.h"
+#include "support.h"
inline __u32 get_mft_record_data_size(const MFT_RECORD *b)
@@ -37,5 +42,5 @@
}
-int flush_mft_entry(const mft_entry *me)
+int flush_mft_entry(mft_entry *me)
{
VCN mref;
@@ -44,4 +49,5 @@
MFT_RECORD *mrec;
__u32 i;
+ ntfs_volume *vol;
if (!MftEntryMapped(me))
@@ -49,5 +55,6 @@
if (MftEntryError(me))
return -EBADF;
- mref = (VCN)(*(__u64*)me->m_ref & MFT_REFERENCE_MASK_CPU);
+ mref = (VCN)MREF(me->m_ref);
+ vol = me->m_vol;
/* Size of mft record != size of cluster thus need to work with offsets
* into clusters. */
@@ -134,5 +141,5 @@
if (MftEntryMapped(me))
return 0;
- mref = (VCN)(*(__u64*)me->m_ref & MFT_REFERENCE_MASK_CPU);
+ mref = (VCN)MREF(*me->m_ref);
mrec = (MFT_RECORD*)malloc(vol->mft_record_size);
if (!mrec)
@@ -205,5 +212,5 @@
}
-int insert_mft_entry(ntfs_volume *vol, mft_entry **me, const MFT_REFERENCE mref,
+int insert_mft_entry(ntfs_volume *vol, mft_entry **me, const MFT_REF mref,
const MFT_RECORD *mrec, const BOOL dirty,
const ntfs_file *f)
@@ -226,9 +233,7 @@
list_for_each(tmp, &vol->mft_entries) {
m = list_entry(tmp, mft_entry, m_list);
- if ((__u64)m->m_ref & MFT_REFERENCE_MASK_CPU <
- (__u64)me->m_ref & MFT_REFERENCE_MASK_CPU)
+ if (MREF(m->m_ref) < MREF(me->m_ref))
continue;
- if ((__u64)m->m_ref & MFT_REFERENCE_MASK_CPU >
- (__u64)me->m_ref & MFT_REFERENCE_MASK_CPU) {
+ if (MREF(m->m_ref) > MREF(me->m_ref)) {
/* Insert the mft entry in the correct position. */
__list_add(&me->m_list, &tmp->m_list->prev,
@@ -238,7 +243,6 @@
fprintf(stderr, "Linux-NTFS: BUG! insert_mft_entry(): mft "
"entry already present in volume.\n");
- if (m->m_ref.sequence_number != me->m_ref.sequence_number &&
- m->m_ref.sequence_number != 0 &&
- me->m_ref.sequence_number != 0)
+ if (MSEQNO(m->m_ref) != MSEQNO(me->m_ref) &&
+ MSEQNO(m->m_ref) != 0 && MSEQNO(me->m_ref) != 0)
fprintf(stderr, "On top of this, the sequence numbers "
"are mismatched.\n");
@@ -310,7 +314,7 @@
return -EBUSY;
f->nr_m_refs--;
- t = realloc(f->m_refs, f->nr_m_refs * sizeof(MFT_REFERENCE));
+ t = realloc(f->m_refs, f->nr_m_refs * sizeof(MFT_REF));
if (t)
- f->m_refs = (MFT_REFERENCE*)t;
+ f->m_refs = (MFT_REF*)t;
t = realloc(f->m_entries, f->nr_m_refs * sizeof(mft_entry*));
if (t)
@@ -332,9 +336,8 @@
me->m_file = f;
for (i = 0; i < f->nr_m_refs; i++)
- if (f->m_refs[i] & MFT_REFERENCE_MASK_CPU ==
- (__u64)me->m_ref & MFT_REFERENCE_MASK_CPU)
+ if (MREF(f->m_refs[i]) == MREF(me->m_ref))
return 0;
f->nr_m_refs++;
- t = realloc(f->m_refs, f->nr_m_refs * sizeof(MFT_REFERENCE));
+ t = realloc(f->m_refs, f->nr_m_refs * sizeof(MFT_REF));
if (!t)
goto undo_add_ret;
@@ -343,5 +346,5 @@
if (!t) {
t = realloc(f->m_refs, (f->nr_m_refs - 1) *
- sizeof(MFT_REFERENCE));
+ sizeof(MFT_REF));
if (t)
f->m_refs = t;
@@ -362,5 +365,5 @@
{
int i;
- MFT_REFERENCE mref = 0ULL;
+ MFT_REF mref = 0ULL;
ntfs_file *f = me->m_file;
if (!f)
@@ -371,6 +374,5 @@
goto not_there;
for (i = 0; i < f->nr_m_refs; i++) {
- if ((__u64)me->m_ref & MFT_REFERENCE_MASK_CPU ==
- (__u64)f->m_refs[i] & MFT_REFERENCE_MASK_CPU) {
+ if (MREF(me->m_ref) == MREF(f->m_refs[i])) {
mref = f->m_refs[i];
break;
@@ -379,6 +381,6 @@
if (!(__u64)mref)
goto not_there;
- if (me->m_ref.sequence_number != mref.sequence_number &&
- me->m_ref.sequence_number != 0 && mref.sequence_number != 0)
+ if (MSEQNO(me->m_ref) != MSEQNO(mref) && MSEQNO(me->m_ref) != 0 &&
+ MSEQNO(mref) != 0)
fprintf(stderr, "Linux-NTFS: BUG() "
"__remove_mft_entry_from_file(): Sequence "
@@ -390,11 +392,11 @@
if (i < f->nr_m_refs) {
memmove(f->m_refs + i, f->m_refs + i + 1,
- (f->nr_m_refs - i) * sizeof(MFT_REFERENCE));
+ (f->nr_m_refs - i) * sizeof(MFT_REF));
memmove(f->m_entries + i, f->m_entries + i + 1,
(f->nr_m_refs - i) * sizeof(mft_entry*));
}
- t = realloc(f->m_refs, f->nr_m_refs * sizeof(MFT_REFERENCE));
+ t = realloc(f->m_refs, f->nr_m_refs * sizeof(MFT_REF));
if (t)
- f->m_refs = (MFT_REFERENCE*)t;
+ f->m_refs = (MFT_REF*)t;
t = realloc(f->m_entries, f->nr_m_refs * sizeof(mft_entry*));
if (t)
@@ -440,5 +442,5 @@
{
/* Add m to f. */
- f->m_refs = (MFT_REFERENCE*)malloc(sizeof(MFT_REFERENCE));
+ f->m_refs = (MFT_REF*)malloc(sizeof(MFT_REF));
if (!f->m_refs)
return -errno;
@@ -462,5 +464,5 @@
}
-ntfs_file *ntfs_open_by_mref(ntfs_volume *vol, const MFT_REFERENCE mref)
+ntfs_file *ntfs_open_by_mref(ntfs_volume *vol, const MFT_REF mref)
{
struct list_head *tmp;
@@ -471,13 +473,10 @@
list_for_each(tmp, &vol->mft_entries) {
m = list_entry(tmp, mft_entry, m_list);
- if ((__u64)m->m_ref & MFT_REFERENCE_MASK_CPU <
- (__u64)mref & MFT_REFERENCE_MASK_CPU)
+ if (MREF(m->m_ref) < MREF(mref))
continue;
- if ((__u64)m->m_ref & MFT_REFERENCE_MASK_CPU >
- (__u64)mref & MFT_REFERENCE_MASK_CPU)
+ if (MREF(m->m_ref) > MREF(mref))
break;
- if (m->m_ref.sequence_number != mref.sequence_number &&
- m->m_ref.sequence_number != 0 &&
- mref.sequence_number != 0) {
+ if (MSEQNO(m->m_ref) != MSEQNO(mref) &&
+ MSEQNO(m->m_ref) != 0 && MSEQNO(mref) != 0) {
fprintf(stderr, "Linux-NTFS: ntfs_open_by_mref(): "
"mft reference sequence numbers do "
@@ -494,6 +493,5 @@
if (f) { /* File is in cache. */
for (i = 0; i < f->nr_m_refs; i++)
- if ((__u64)f->m_refs[i] & MFT_REFERENCE_MASK_CPU ==
- (__u64)mref & MFT_REFERENCE_MASK_CPU)
+ if (MREF(f->m_refs[i]) == MREF(mref))
break;
/* Only base mft records can be opened as files. */
Index: ntfs_rec.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/ntfs_rec.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -U2 -r1.5 -r1.6
--- ntfs_rec.c 2001/04/08 03:02:55 1.5
+++ ntfs_rec.c 2001/04/11 11:49:16 1.6
@@ -25,4 +25,5 @@
#include "ntfs_rec.h"
+#include "layout.h"
#include "endians.h"
Index: volume.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/volume.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -U2 -r1.13 -r1.14
--- volume.c 2001/04/10 23:37:19 1.13
+++ volume.c 2001/04/11 11:49:16 1.14
@@ -29,13 +29,15 @@
#include <unistd.h>
#include <linux/types.h>
-#include <linux/list.h>
-#include "endians.h"
-#include "attrib.h"
+#include "list.h"
+#include "layout.h"
#include "volume.h"
+#include "types.h"
+#include "support.h"
#include "bootsect.h"
#include "disk_io.h"
+#include "endians.h"
+#include "attrib.h"
#include "mft.h"
-#include "support.h"
BOOL ntfs_sync_volume(ntfs_volume *vol)
@@ -69,5 +71,5 @@
__s8 c;
attr_search_context ctx;
- MFT_REFERENCE mref;
+ MFT_REF mref;
int err;
@@ -328,5 +330,5 @@
/* Now load the bitmap from $Bitmap. */
printf("Loading $Bitmap... ");
- mref = (MFT_REFERENCE)(__u64)FILE_$BitMap;
+ mref = (MFT_REF)FILE_$BitMap;
if (err = read_file_record(vol, &mref, &mb, NULL)) {
puts(FAILED);
@@ -373,5 +375,5 @@
/* Now load the upcase table from $UpCase. */
printf("Loading $UpCase... ");
- mref = (MFT_REFERENCE)(__u64)FILE_$UpCase;
+ mref = (MFT_REF)FILE_$UpCase;
if (err = read_file_record(vol, &mref, &mb, NULL)) {
puts(FAILED);
@@ -430,5 +432,5 @@
* vol structure accordingly. */
printf("Loading $Volume... ");
- mref = (MFT_REFERENCE)(__u64)FILE_$Volume;
+ mref = (MFT_REF)FILE_$Volume;
if (err = read_file_record(vol, &mref, &mb, NULL)) {
puts(FAILED);
|