Some modifications to VFS-filename conversion
Tomoki AONO
aono at cc.osaka-kyoiku.ac.jp
Tue Mar 28 13:30:50 GMT 2000
I tested against main branch (cvs checkout in Mar 22 11:35
JST(+0900)) whether smbd can correctly handle Japanese
filename. I use coding system=cap. (Maybe coding
system=sjis (Shift_JIS) works because Windows 95 use sjis
character.)
I found some failed function. I saw source also (and found
some errata), and made a simple patch against main branch.
Changes:
- Both arguments of vfs_ops.rename() are unix filename
(needs dos_to_unix()) to handle Japanese filename
correctly.
- In OpenDir() (smbd/dir.c), return value of
vfs_readdirname() was already converted filename. So no
need to use unix_to_dos() again. This is fault of my
first patch (posted to samba-bugs). (And it seems
vfs_readdirname() calls unix_to_dos() two times, but I
don't know why.)
----
Tomoki AONO (aono at cc.osaka-kyoiku.ac.jp)
-------------- next part --------------
--- smbd/reply.c-1.203 Wed Mar 22 11:47:48 2000
+++ smbd/reply.c Wed Mar 22 11:38:35 2000
@@ -3570,6 +3570,7 @@
int error = ERRnoaccess;
BOOL exists=False;
BOOL rc = True;
+ pstring zdirectory;
*directory = *mask = 0;
@@ -3667,23 +3668,29 @@
}
}
+ /*
+ * resolve_wildcards() does not break newname
+ * (as no '?' in newname), but for safety,
+ * dos_to_unix() to directory (not newname).
+ */
+ pstrcpy(zdirectory, dos_to_unix(directory, False));
if(replace_if_exists) {
/*
* NT SMB specific flag - rename can overwrite
* file with the same name so don't check for
- * dos_file_exist().
+ * vfs_file_exist().
*/
if(resolve_wildcards(directory,newname) &&
can_rename(directory,conn) &&
- !conn->vfs_ops.rename(dos_to_unix(directory,False),
- newname))
+ !conn->vfs_ops.rename(zdirectory,
+ dos_to_unix(newname,False)))
count++;
} else {
if (resolve_wildcards(directory,newname) &&
can_rename(directory,conn) &&
!vfs_file_exist(conn,newname,NULL) &&
- !conn->vfs_ops.rename(dos_to_unix(directory,False),
- newname))
+ !conn->vfs_ops.rename(zdirectory,
+ dos_to_unix(newname,False)))
count++;
}
@@ -3713,7 +3720,7 @@
pstrcpy(mask,"*");
while ((dname = ReadDirName(dirptr))) {
- pstring fname;
+ pstring fname, zdestname;
pstrcpy(fname,dname);
if(!mask_match(fname, mask, case_sensitive, False))
@@ -3740,8 +3747,9 @@
continue;
}
+ pstrcpy(zdestname, dos_to_unix(destname, False));
if (!conn->vfs_ops.rename(dos_to_unix(fname,False),
- destname))
+ zdestname))
count++;
DEBUG(3,("rename_internals: doing rename on %s -> %s\n",fname,destname));
}
--- smbd/dir.c-1.44 Fri Feb 4 11:39:18 2000
+++ smbd/dir.c Mon Mar 27 15:58:32 2000
@@ -684,14 +684,15 @@
while ((n = vfs_readdirname(conn, p)))
{
- int l;
- pstring zn;
-
- pstrcpy(zn, unix_to_dos(n,True));
- l = strlen(zn)+1;
+ int l = strlen(n)+1;
+
+ /*
+ * return value of vfs_readdirname is already unix_to_dos()-ed, so
+ * (probably) no need to unix_to_dos() to n.
+ */
/* If it's a vetoed file, pretend it doesn't even exist */
- if (use_veto && conn && IS_VETO_PATH(conn, zn)) continue;
+ if (use_veto && conn && IS_VETO_PATH(conn, n)) continue;
if (used + l > dirp->mallocsize) {
int s = MAX(used+l,used+2000);
@@ -705,7 +706,7 @@
dirp->mallocsize = s;
dirp->current = dirp->data;
}
- pstrcpy(dirp->data+used,zn);
+ pstrcpy(dirp->data+used,n);
used += l;
dirp->numentries++;
}
More information about the samba-technical
mailing list