From d15ed62ae402330a44a79fe55c5ec3746fb149ea Mon Sep 17 00:00:00 2001 From: yura Date: Mon, 14 Aug 2006 03:52:56 +0000 Subject: [PATCH] a bit of cleanups --- libntfs/attrib.c | 2 +- libntfs/dir.c | 3 ++- ntfsprogs/ntfscp.c | 39 ++++++++++----------------------------- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/libntfs/attrib.c b/libntfs/attrib.c index 2f18a810..cf4f157e 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -4991,7 +4991,7 @@ put_err_out: * EOPNOTSUPP - The desired resize is not implemented yet. */ int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize) -{ +{ int ret; if (!na || newsize < 0 || diff --git a/libntfs/dir.c b/libntfs/dir.c index e7859c2a..d49a2772 100644 --- a/libntfs/dir.c +++ b/libntfs/dir.c @@ -549,7 +549,8 @@ ntfs_inode *ntfs_pathname_to_inode(ntfs_volume *vol, ntfs_inode *parent, len = ntfs_mbstoucs(p, &unicode, MAX_PATH); if (len < 0) { - ntfs_log_debug("Couldn't convert name to Unicode: %s.\n", p); + ntfs_log_debug("Couldn't convert name to Unicode: " + "%s.\n", p); err = EILSEQ; goto close; } diff --git a/ntfsprogs/ntfscp.c b/ntfsprogs/ntfscp.c index f8e703e3..90c754a3 100644 --- a/ntfsprogs/ntfscp.c +++ b/ntfsprogs/ntfscp.c @@ -1,7 +1,7 @@ /** * ntfscp - Part of the Linux-NTFS project. * - * Copyright (c) 2004-2005 Yura Pakhuchiy + * Copyright (c) 2004-2006 Yura Pakhuchiy * Copyright (c) 2005 Anton Altaparmakov * * This utility will overwrite files on NTFS volume. @@ -81,7 +81,7 @@ static void version(void) { ntfs_log_info("\n%s v%s (libntfs %s) - Overwrite files on NTFS " "volume.\n\n", EXEC_NAME, VERSION, ntfs_libntfs_version()); - ntfs_log_info("Copyright (c) 2004-2005 Yura Pakhuchiy\n"); + ntfs_log_info("Copyright (c) 2004-2006 Yura Pakhuchiy\n"); ntfs_log_info("\n%s\n%s%s\n", ntfs_gpl, ntfs_bugs, ntfs_home); } @@ -355,37 +355,18 @@ int main(int argc, char *argv[]) ntfs_log_perror("ERROR: Couldn't open destination file"); goto close_src; } - if ((le16_to_cpu(out->mrec->flags) & MFT_RECORD_IS_DIRECTORY) && - !opts.inode){ - /* + if ((out->mrec->flags & MFT_RECORD_IS_DIRECTORY) && !opts.inode) { + /* * @out is directory and it was specified by pathname, add - * filename to path and reopen inode. + * filename to path and try once again. */ - char *filename, *new_dest_file; + char *filename; + ntfs_inode *out_tmp; - /* - * FIXME: There should exist more beautiful way to get filename. - * Not sure that it will work in windows, but I don't think that - * someone will use ntfscp under windows. - */ - filename = strrchr(opts.src_file, '/'); - if (filename) - filename++; - else - filename = opts.src_file; - /* Add 2 bytes for '/' and null-terminator. */ - new_dest_file = malloc(strlen(opts.dest_file) + - strlen(filename) + 2); - if (!new_dest_file) { - ntfs_log_perror("ERROR: malloc() failed"); - goto close_dst; - } - strcpy(new_dest_file, opts.dest_file); - strcat(new_dest_file, "/"); - strcat(new_dest_file, filename); + filename = basename(opts.src_file); + out_tmp = ntfs_pathname_to_inode(vol, out, filename); ntfs_inode_close(out); - out = ntfs_pathname_to_inode(vol, NULL, new_dest_file); - free(new_dest_file); + out = out_tmp; if (!out) { ntfs_log_perror("ERROR: Failed to open destination " "file");