Changes by: cha0smaster
Update of /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29034/ntfsprogs
Modified Files:
ntfsinfo.c ntfsls.c ntfsmount.c ntfsrm.c ntfsundelete.c
Log Message:
Sorry it's very large commit (46K of diffs between my local tree and CVS HEAD
before commit), file and directory creation/deletion recursively requested many
changes. See ChangeLog for description of all changes.
Index: ntfsinfo.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsinfo.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -p -r1.73 -r1.74
--- ntfsinfo.c 4 Aug 2005 09:59:44 -0000 1.73
+++ ntfsinfo.c 14 Aug 2005 15:44:47 -0000 1.74
@@ -280,7 +280,7 @@ static int parse_options (int argc, char
*/
static char *ntfsinfo_time_to_str(const s64 sle_ntfs_clock)
{
- time_t unix_clock = ntfs2utc(sle64_to_cpu(sle_ntfs_clock));
+ time_t unix_clock = ntfs2utc(sle_ntfs_clock);
return ctime(&unix_clock);
}
@@ -450,11 +450,11 @@ static void ntfs_dump_flags(ATTR_TYPES t
}
if (type == AT_FILE_NAME) {
if (flags & FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT) {
- printf(" DIRECTORY");
+ printf(" FILE_NAME_INDEX");
flags &= ~FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT;
}
if (flags & FILE_ATTR_DUP_VIEW_INDEX_PRESENT) {
- printf(" INDEX_VIEW");
+ printf(" VIEW_INDEX");
flags &= ~FILE_ATTR_DUP_VIEW_INDEX_PRESENT;
}
}
Index: ntfsls.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsls.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -p -r1.27 -r1.28
--- ntfsls.c 11 Aug 2005 13:53:08 -0000 1.27
+++ ntfsls.c 14 Aug 2005 15:44:48 -0000 1.28
@@ -548,8 +548,7 @@ static int list_dir_entry(ntfsls_dirent
if (!file_name_attr)
goto release;
- ntfs_time = ntfs2utc(sle64_to_cpu(
- file_name_attr->last_data_change_time));
+ ntfs_time = ntfs2utc(file_name_attr->last_data_change_time);
strcpy(t_buf, ctime(&ntfs_time));
memmove(t_buf+16, t_buf+19, 5);
t_buf[21] = '\0';
Index: ntfsmount.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmount.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -p -r1.22 -r1.23
--- ntfsmount.c 8 Aug 2005 13:14:41 -0000 1.22
+++ ntfsmount.c 14 Aug 2005 15:44:48 -0000 1.23
@@ -33,6 +33,7 @@
#include <locale.h>
#include <signal.h>
#include <limits.h>
+#include <time.h>
#ifdef HAVE_SETXATTR
#include <sys/xattr.h>
@@ -285,9 +286,9 @@ static int ntfs_fuse_getattr(const char
stbuf->st_uid = ctx->uid;
stbuf->st_gid = ctx->gid;
stbuf->st_ino = ni->mft_no;
- stbuf->st_atime = ni->atime;
- stbuf->st_ctime = ni->ctime;
- stbuf->st_mtime = ni->mtime;
+ stbuf->st_atime = ni->last_access_time;
+ stbuf->st_ctime = ni->last_mft_change_time;
+ stbuf->st_mtime = ni->last_data_change_time;
ntfs_inode_close(ni);
} else
res = -ENOENT;
@@ -518,71 +519,166 @@ static int ntfs_fuse_chmod(const char *p
return -EOPNOTSUPP;
}
-static int ntfs_fuse_mknod(const char *org_path, mode_t mode,
- dev_t dev __attribute__((unused)))
+static int ntfs_fuse_create(const char *org_path, const unsigned type)
{
- ntfs_inode *ni = NULL;
- ntfs_attr *na;
- char *path = NULL;
- ntfschar *stream_name;
- int stream_name_len;
- int res = 0;
+ char *name;
+ ntfschar *uname = NULL;
+ ntfs_inode *dir_ni = NULL, *ni;
+ char *path;
+ int res = 0, uname_len;
- if (mode && !(mode & S_IFREG))
- return -EOPNOTSUPP;
- stream_name_len = ntfs_fuse_parse_path(org_path, &path, &stream_name);
- if (stream_name_len < 0)
- return stream_name_len;
- if (!stream_name_len) {
- res = -EOPNOTSUPP;
+ path = strdup(org_path);
+ if (!path)
+ return -errno;
+ /* Generate unicode filename. */
+ name = strrchr(path, '/');
+ name++;
+ uname_len = ntfs_mbstoucs(name, &uname, 0);
+ if (uname_len < 0) {
+ res = -errno;
goto exit;
}
- ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
- if (!ni) {
+ /* Open parent directory. */
+ *name = 0;
+ dir_ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
+ if (!dir_ni) {
res = -errno;
if (res == -ENOENT)
- res = -EOPNOTSUPP;
+ res = -EIO;
goto exit;
}
- na = ntfs_attr_add(ni, AT_DATA, stream_name, stream_name_len, 0);
- if (na)
- ntfs_attr_close(na);
+ /* Create object specified in @type. */
+ ni = ntfs_create(dir_ni, uname, uname_len, type);
+ if (ni)
+ ntfs_inode_close(ni);
else
res = -errno;
exit:
- if (ni && ntfs_inode_close(ni))
- perror("Failed to close inode");
+ if (uname)
+ free(uname);
+ if (dir_ni)
+ ntfs_inode_close(dir_ni);
free(path);
- if (stream_name_len)
- free(stream_name);
return res;
}
-static int ntfs_fuse_rm_file(char *file)
+static int ntfs_fuse_create_stream(const char *path,
+ ntfschar *stream_name, const int stream_name_len)
{
- free(file);
- return -EOPNOTSUPP;
+ ntfs_inode *ni;
+ ntfs_attr *na;
+ int res = 0;
+
+ ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
+ if (!ni) {
+ res = -errno;
+ if (res == -ENOENT) {
+ /*
+ * If such file does not exist, create it and try once
+ * again to add stream to it.
+ */
+ res = ntfs_fuse_create(path, NTFS_DT_REG);
+ if (!res)
+ return ntfs_fuse_create_stream(path,
+ stream_name, stream_name_len);
+ else
+ res = -errno;
+ }
+ return res;
+ }
+ na = ntfs_attr_add(ni, AT_DATA, stream_name, stream_name_len, 0);
+ if (na)
+ ntfs_attr_close(na);
+ else
+ res = -errno;
+ if (ntfs_inode_close(ni))
+ perror("Failed to close inode");
+ return res;
}
-static int ntfs_fuse_unlink(const char *org_path)
+static int ntfs_fuse_mknod(const char *org_path, mode_t mode,
+ dev_t dev __attribute__((unused)))
{
- ntfs_inode *ni = NULL;
- ntfs_attr *na;
char *path = NULL;
ntfschar *stream_name;
int stream_name_len;
int res = 0;
+ if (mode && !(mode & S_IFREG))
+ return -EOPNOTSUPP;
stream_name_len = ntfs_fuse_parse_path(org_path, &path, &stream_name);
if (stream_name_len < 0)
return stream_name_len;
if (!stream_name_len)
- return ntfs_fuse_rm_file(path);
- ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
+ res = ntfs_fuse_create(path, NTFS_DT_REG);
+ else
+ res = ntfs_fuse_create_stream(path, stream_name,
+ stream_name_len);
+ free(path);
+ if (stream_name_len)
+ free(stream_name);
+ return res;
+}
+
+static int ntfs_fuse_rm(const char *org_path)
+{
+ char *name;
+ ntfschar *uname = NULL;
+ ntfs_inode *dir_ni = NULL, *ni;
+ char *path;
+ int res = 0, uname_len;
+
+ path = strdup(org_path);
+ if (!path)
+ return -errno;
+ /* Open object for delete. */
+ ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
if (!ni) {
res = -errno;
goto exit;
}
+ /* Generate unicode filename. */
+ name = strrchr(path, '/');
+ name++;
+ uname_len = ntfs_mbstoucs(name, &uname, 0);
+ if (uname_len < 0) {
+ res = -errno;
+ goto exit;
+ }
+ /* Open parent directory. */
+ *name = 0;
+ dir_ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
+ if (!dir_ni) {
+ res = -errno;
+ if (res == -ENOENT)
+ res = -EIO;
+ goto exit;
+ }
+ /* Delete object. */
+ if (ntfs_delete(ni, dir_ni, uname, uname_len))
+ res = -errno;
+ ni = NULL;
+exit:
+ if (ni)
+ ntfs_inode_close(ni);
+ if (uname)
+ free(uname);
+ if (dir_ni)
+ ntfs_inode_close(dir_ni);
+ free(path);
+ return res;
+}
+
+static int ntfs_fuse_rm_stream(const char *path, ntfschar *stream_name,
+ const int stream_name_len)
+{
+ ntfs_inode *ni;
+ ntfs_attr *na;
+ int res = 0;
+
+ ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
+ if (!ni)
+ return -errno;
na = ntfs_attr_open(ni, AT_DATA, stream_name, stream_name_len);
if (!na) {
res = -errno;
@@ -593,14 +689,70 @@ static int ntfs_fuse_unlink(const char *
ntfs_attr_close(na);
}
exit:
- if (ni && ntfs_inode_close(ni))
+ if (ntfs_inode_close(ni))
perror("Failed to close inode");
+ return res;
+}
+
+static int ntfs_fuse_unlink(const char *org_path)
+{
+ char *path = NULL;
+ ntfschar *stream_name;
+ int stream_name_len;
+ int res = 0;
+
+ stream_name_len = ntfs_fuse_parse_path(org_path, &path, &stream_name);
+ if (stream_name_len < 0)
+ return stream_name_len;
+ if (!stream_name_len)
+ res = ntfs_fuse_rm(path);
+ else
+ res = ntfs_fuse_rm_stream(path, stream_name, stream_name_len);
free(path);
if (stream_name_len)
free(stream_name);
return res;
}
+static int ntfs_fuse_mkdir(const char *path,
+ mode_t mode __attribute__((unused)))
+{
+ return ntfs_fuse_create(path, NTFS_DT_DIR);
+}
+
+static int ntfs_fuse_rmdir(const char *path)
+{
+ return ntfs_fuse_rm(path);
+}
+
+static int ntfs_fuse_utime(const char *path, struct utimbuf *buf)
+{
+ ntfs_inode *ni;
+
+ if (strchr(path, ':'))
+ return 0; /* Unable to change time for named data streams. */
+ ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
+ if (!ni)
+ return -errno;
+ if (buf) {
+ ni->last_access_time = buf->actime;
+ ni->last_data_change_time = buf->modtime;
+ ni->last_mft_change_time = buf->modtime;
+ } else {
+ 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);
+ NInoSetDirty(ni);
+ if (ntfs_inode_close(ni))
+ perror("Failed to close inode");
+ return 0;
+}
+
#ifdef HAVE_SETXATTR
static int ntfs_fuse_getxattr(const char *path, const char *name,
@@ -883,6 +1035,9 @@ static struct fuse_operations ntfs_fuse_
.chmod = ntfs_fuse_chmod,
.mknod = ntfs_fuse_mknod,
.unlink = ntfs_fuse_unlink,
+ .mkdir = ntfs_fuse_mkdir,
+ .rmdir = ntfs_fuse_rmdir,
+ .utime = ntfs_fuse_utime,
#ifdef HAVE_SETXATTR
.getxattr = ntfs_fuse_getxattr,
#if 0
Index: ntfsrm.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsrm.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -p -r1.51 -r1.52
--- ntfsrm.c 14 Aug 2005 12:26:55 -0000 1.51
+++ ntfsrm.c 14 Aug 2005 15:44:48 -0000 1.52
@@ -276,7 +276,7 @@ static void ntfs_binary_print (u8 num, B
*/
static const char * ntfsinfo_time_to_str(const s64 sle_ntfs_clock)
{
- time_t unix_clock = ntfs2utc(sle64_to_cpu(sle_ntfs_clock));
+ time_t unix_clock = ntfs2utc(sle_ntfs_clock);
if (sle_ntfs_clock == 0)
return "none\n";
else
Index: ntfsundelete.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfsprogs/ntfsprogs/ntfsundelete.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -p -r1.44 -r1.45
--- ntfsundelete.c 4 Aug 2005 09:59:45 -0000 1.44
+++ ntfsundelete.c 14 Aug 2005 15:44:48 -0000 1.45
@@ -876,10 +876,10 @@ static int get_filenames (struct ufile *
name->size_data = sle64_to_cpu (attr->data_size);
name->flags = attr->file_attributes;
- name->date_c = ntfs2utc (sle64_to_cpu (attr->creation_time));
- name->date_a = ntfs2utc (sle64_to_cpu (attr->last_data_change_time));
- name->date_m = ntfs2utc (sle64_to_cpu (attr->last_mft_change_time));
- name->date_r = ntfs2utc (sle64_to_cpu (attr->last_access_time));
+ name->date_c = ntfs2utc (attr->creation_time);
+ name->date_a = ntfs2utc (attr->last_data_change_time);
+ name->date_m = ntfs2utc (attr->last_mft_change_time);
+ name->date_r = ntfs2utc (attr->last_access_time);
if (ntfs_ucstombs (name->uname, name->uname_len, &name->name,
0) < 0) {
@@ -1052,7 +1052,7 @@ static struct ufile * read_record (ntfs_
if (attr10) {
STANDARD_INFORMATION *si;
si = (STANDARD_INFORMATION *) ((char *) attr10 + le16_to_cpu (attr10->value_offset));
- file->date = ntfs2utc (sle64_to_cpu (si->last_data_change_time));
+ file->date = ntfs2utc (si->last_data_change_time);
}
if (attr20 || !attr10)
|