[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ntfs-cvs
Subject: [Linux-NTFS-cvs] CVS: linux-ntfs/ntfstools mkntfs.c,1.73,1.74 ntfsfix.c,1.29,1.30 ntfslabel.c,1.10,1
From: Anton Altaparmakov <antona () users ! sourceforge ! net>
Date: 2002-04-27 19:49:12
[Download RAW message or body]
Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/ntfstools
In directory usw-pr-cvs1:/tmp/cvs-serv24579/ntfstools
Modified Files:
mkntfs.c ntfsfix.c ntfslabel.c
Log Message:
Update library, new APIs ntfs_attr_find_vcn(), misc fixes and cleanups, make all the \
utilities compile, fix bugs I noticed in ntfslabel and it now works properly.
Index: mkntfs.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/mkntfs.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -U2 -r1.73 -r1.74
--- mkntfs.c 23 Apr 2002 23:27:33 -0000 1.73
+++ mkntfs.c 27 Apr 2002 19:49:10 -0000 1.74
@@ -120,5 +120,4 @@
/* Need these global so mkntfs_exit can access them. */
-int f;
struct flock flk;
char *buf = NULL;
@@ -145,5 +144,5 @@
g or G for GB, or t or T for TB */
int index_block_size; /* in bytes. */
- int mft_size; /* The smaller of 16kB & one cluster. */
+ int mft_size; /* The bigger of 16kB & one cluster. */
long long mft_lcn; /* lcn of $MFT, $DATA attribute. */
long long mftmirr_lcn; /* lcn of $MFTMirr, $DATA. */
@@ -420,5 +419,5 @@
/**
- * ucstos - convert ASCII string to unicode-character string
+ * stoucs - convert ASCII string to unicode-character string
* @dest: points to buffer to receive the converted string
* @src: points to string to convert
@@ -1313,5 +1312,5 @@
} else {
a->compression_unit = 0;
- bw = ntfs_rlwrite(f, rl, val, val_len, &inited_size);
+ bw = ntfs_rlwrite(vol->fd, rl, val, val_len, &inited_size);
if (bw != val_len)
Eprintf("Error writing non-resident attribute value."
@@ -1493,5 +1492,5 @@
} else {
a->compression_unit = 0;
- bw = ntfs_rlwrite(f, rl, val, val_len, NULL);
+ bw = ntfs_rlwrite(vol->fd, rl, val, val_len, NULL);
if (bw != val_len)
Eprintf("Error writing non-resident attribute value."
@@ -2441,7 +2440,4 @@
}
-
-
-
void init_options()
{
@@ -2586,15 +2582,15 @@
if (vol->upcase)
free(vol->upcase);
- if (vol)
- free(vol);
flk.l_type = F_UNLCK;
- err = fcntl(f, F_SETLK, &flk);
+ err = fcntl(vol->fd, F_SETLK, &flk);
if (err == -1)
Eprintf("Warning: Could not unlock %s: %s\n", vol->dev_name,
strerror(errno));
- err = close(f);
+ err = close(vol->fd);
if (err == -1)
Eprintf("Warning: Could not close %s: %s\n", vol->dev_name,
strerror(errno));
+ if (vol)
+ free(vol);
}
@@ -2743,6 +2739,6 @@
} else
i = O_RDWR;
- f = open(vol->dev_name, i);
- if (f == -1)
+ vol->fd = open(vol->dev_name, i);
+ if (vol->fd == -1)
err_exit("Could not open %s: %s\n", vol->dev_name,
strerror(errno));
@@ -2755,10 +2751,10 @@
flk.l_whence = SEEK_SET;
flk.l_start = flk.l_len = 0LL;
- err = fcntl(f, F_SETLK, &flk);
+ err = fcntl(vol->fd, F_SETLK, &flk);
if (err == -1) {
Eprintf("Could not lock %s for %s: %s\n", vol->dev_name,
opt.no_action ? "reading" : "writing",
strerror(errno));
- err = close(f);
+ err = close(vol->fd);
if (err == -1)
Eprintf("Warning: Could not close %s: %s\n",
@@ -2779,5 +2775,5 @@
int _sect_size = 0;
- if (ioctl(f, BLKSSZGET, &_sect_size) >= 0)
+ if (ioctl(vol->fd, BLKSSZGET, &_sect_size) >= 0)
opt.sector_size = _sect_size;
else
@@ -2800,5 +2796,5 @@
/* If user didn't specify the number of sectors, determine it now. */
if (!opt.nr_sectors) {
- opt.nr_sectors = get_device_size(f, opt.sector_size);
+ opt.nr_sectors = get_device_size(vol->fd, opt.sector_size);
if (opt.nr_sectors <= 0)
err_exit("get_device_size(%s) failed. Please specify "
@@ -3118,5 +3114,5 @@
fflush(stdout);
}
- bw = mkntfs_write(f, buf, vol->cluster_size);
+ bw = mkntfs_write(vol->fd, buf, vol->cluster_size);
if (bw != vol->cluster_size) {
if (bw != -1 || errno != EIO)
@@ -3140,5 +3136,5 @@
position / progress_inc);
/* Seek to next cluster. */
- lseek(f, ((off_t)position + 1) *
+ lseek(vol->fd, ((off_t)position + 1) *
vol->cluster_size, SEEK_SET);
}
@@ -3148,5 +3144,5 @@
opt.sector_size;
for (i = 0; i < position; i++) {
- bw = mkntfs_write(f, buf, opt.sector_size);
+ bw = mkntfs_write(vol->fd, buf, opt.sector_size);
if (bw != opt.sector_size) {
if (bw != -1 || errno != EIO)
@@ -3160,5 +3156,5 @@
"file $Boot.\n");
/* Seek to next sector. */
- lseek(f, opt.sector_size, SEEK_CUR);
+ lseek(vol->fd, opt.sector_size, SEEK_CUR);
}
}
@@ -3466,8 +3462,8 @@
* last sector.
*/
- if (lseek(f, (opt.nr_sectors + 1) * opt.sector_size - i, SEEK_SET) ==
- (off_t)-1)
+ if (lseek(vol->fd, (opt.nr_sectors + 1) * opt.sector_size - i,
+ SEEK_SET) == (off_t)-1)
goto bb_err;
- bw = mkntfs_write(f, buf2, i);
+ bw = mkntfs_write(vol->fd, buf2, i);
free(buf2);
buf2 = NULL;
@@ -3607,5 +3603,5 @@
err_exit("ntfs_pre_write_mst_fixup() failed while syncing "
"root directory index block.\n");
- lw = ntfs_rlwrite(f, rl_index, (char*)index_block, i, NULL);
+ lw = ntfs_rlwrite(vol->fd, rl_index, (char*)index_block, i, NULL);
if (lw != i)
err_exit("Error writing $INDEX_ALLOCATION.\n");
@@ -3628,6 +3624,6 @@
if (!rl)
err_exit("ntfs_decompress_mapping_pairs() failed\n");
- lw = ntfs_rlwrite(f, rl, lcn_bitmap, lcn_bitmap_byte_size,
- NULL);
+ lw = ntfs_rlwrite(vol->fd, rl, lcn_bitmap,
+ lcn_bitmap_byte_size, NULL);
if (lw != lcn_bitmap_byte_size)
err_exit("%s\n", lw == -1 ? strerror(errno) :
@@ -3644,8 +3640,9 @@
Vprintf("Syncing $MFT.\n");
pos = opt.mft_lcn * vol->cluster_size;
- lw = vol->mft_record_size;
+ lw = 1;
for (i = 0; i < opt.mft_size / vol->mft_record_size; i++) {
if (!opt.no_action)
- lw = ntfs_mst_pwrite(f, pos, 1, vol->mft_record_size,
+ lw = ntfs_mst_pwrite(vol->fd, pos, 1,
+ vol->mft_record_size,
buf + i * vol->mft_record_size);
if (lw != 1)
@@ -3656,5 +3653,5 @@
Vprintf("Updating $MFTMirr.\n");
pos = opt.mftmirr_lcn * vol->cluster_size;
- lw = vol->mft_record_size;
+ lw = 1;
for (i = 0; i < rl_mftmirr[0].length * vol->cluster_size /
vol->mft_record_size; i++) {
@@ -3673,5 +3670,6 @@
*usnp = cpu_to_le16(usn);
if (!opt.no_action)
- lw = ntfs_mst_pwrite(f, pos, 1, vol->mft_record_size,
+ lw = ntfs_mst_pwrite(vol->fd, pos, 1,
+ vol->mft_record_size,
buf + i * vol->mft_record_size);
if (lw != 1)
@@ -3681,5 +3679,5 @@
}
Vprintf("Syncing device.\n");
- if (fdatasync(f) == -1)
+ if (fdatasync(vol->fd) == -1)
err_exit("Syncing device. FAILED: %s", strerror(errno));
Qprintf("mkntfs completed successfully. Have a nice day.\n");
Index: ntfsfix.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfsfix.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -U2 -r1.29 -r1.30
--- ntfsfix.c 21 Apr 2002 01:26:39 -0000 1.29
+++ ntfsfix.c 27 Apr 2002 19:49:10 -0000 1.30
@@ -218,12 +218,12 @@
printf("Comparing $MftMirr to $Mft... ");
for (i = 0, ebits = 0; i < 4; ++i) {
- if (memcmp(b1+i*mrs, b2+i*mrs,
- get_mft_record_data_size((MFT_RECORD*)(b1 +
- i * mrs)))) {
+ if (memcmp(b1 + i * mrs, b2 + i * mrs,
+ ntfs_get_mft_record_data_size((MFT_RECORD*)(b1
+ + i * mrs)))) {
ebits |= 1 << i;
#ifdef DEBUG
printf("in memcmp: i = %x, count = 0x%x\n", i,
- get_mft_record_data_size((MFT_RECORD*)(b1
- + i * mrs)));
+ ntfs_get_mft_record_data_size(
+ (MFT_RECORD*)(b1 + i * mrs)));
#endif
}
Index: ntfslabel.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/ntfstools/ntfslabel.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -U2 -r1.10 -r1.11
--- ntfslabel.c 25 Apr 2002 18:31:20 -0000 1.10
+++ ntfslabel.c 27 Apr 2002 19:49:10 -0000 1.11
@@ -126,4 +126,6 @@
}
+int stoucs(uchar_t * dest, const char *src, int maxlen);
+
/**
* change_label - change the current label on a device
@@ -133,9 +135,8 @@
* change_label will first verify the device is a valid block
* device, and will exit with error INVALID_BLOCK_DEVICE if
-r * it is not. it will also verify the device is not currently
+ * it is not. it will also verify the device is not currently
* mounted and exit with error NTFS_MF_MOUNTED if it is
- **/
-void
-change_label(const char *dev, const char *label)
+ */
+void change_label(const char *dev, const char *label)
{
@@ -209,7 +210,7 @@
}
-
- stoucs(new_label,label,label_len);
- label_len = sizeof(uchar_t) * label_len;
+ new_label = malloc((label_len + 1) * sizeof(uchar_t));
+ label_len = stoucs(new_label,label,(label_len + 1) *
+ sizeof(uchar_t)) * sizeof(uchar_t);
if (resize_resident_attribute_value(mrec, a, label_len)) {
@@ -218,6 +219,6 @@
}
- printf("%s\n",label);
- memcpy((char*)a + le16_to_cpu(a->value_offset), label, \
min(le32_to_cpu(a->value_length), label_len)); + memcpy((char*)a + \
le16_to_cpu(a->value_offset), new_label, + min(le32_to_cpu(a->value_length), \
label_len));
@@ -246,8 +247,4 @@
exit(1);
}
-
-
-
-
}
@@ -265,6 +262,5 @@
/* New attribute length and mft record bytes used. */
- new_alen = (le32_to_cpu(a->length) - le32_to_cpu(a->value_length) +
- new_vsize + 7) & ~7;
+ new_alen = (le16_to_cpu(a->value_offset) + new_vsize + 7) & ~7;
new_muse = le32_to_cpu(m->bytes_in_use) - le32_to_cpu(a->length) +
new_alen;
@@ -308,2 +304,3 @@
return i;
}
+
_______________________________________________
Linux-NTFS-cvs mailing list
Linux-NTFS-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-ntfs-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic