1
1

* smbfs.c (open_readwrite): New function to replace open_read()

and open_write().  Use cli_close() if cli_qfileinfo() or
cli_getattrE() fail.

(smbfs_open): Use open_readwrite(). Free remote_handle if
open_readwrite() fails.
Этот коммит содержится в:
Andrew V. Samoilov 2003-04-03 10:45:03 +00:00
родитель ebf1bcfa33
Коммит 6f188101cf
2 изменённых файлов: 70 добавлений и 69 удалений

Просмотреть файл

@ -1,3 +1,12 @@
2003-04-03 Andrew V. Samoilov <sav@bcs.zp.ua>
* smbfs.c (open_readwrite): New function to replace open_read()
and open_write(). Use cli_close() if cli_qfileinfo() or
cli_getattrE() fail.
(smbfs_open): Use open_readwrite(). Free remote_handle if
open_readwrite() fails.
2003-03-24 Adam Byrtek <alpha@debian.org> 2003-03-24 Adam Byrtek <alpha@debian.org>
* extfs/patchfs.in: Treat '\ No newline at end of file' line * extfs/patchfs.in: Treat '\ No newline at end of file' line
@ -1162,7 +1171,7 @@
* smbfs.c (smbfs_add_dots): New function. Insert a "." and ".." * smbfs.c (smbfs_add_dots): New function. Insert a "." and ".."
entries into the linked list. entries into the linked list.
(smbfs_loaddir): Call smbfs_add_dots for shares or servers. (smbfs_loaddir): Call smbfs_add_dots() for shares or servers.
(smbfs_get_free_bucket): Eliminate time. (smbfs_get_free_bucket): Eliminate time.
(fake_share_stat): Make path const. (fake_share_stat): Make path const.
@ -1194,7 +1203,7 @@
By David Kaelbling <drk@sgi.com>. By David Kaelbling <drk@sgi.com>.
http://bugzilla.gnome.org/show_bug.cgi?id=60933 http://bugzilla.gnome.org/show_bug.cgi?id=60933
* cpio.c (cpio_read_bin_head): Release name if mc_read fails. * cpio.c (cpio_read_bin_head): Release name if mc_read() fails.
(cpio_read_crc_head): Likewise. (cpio_read_crc_head): Likewise.
2001-10-25 Andrew V. Samoilov <kai@cmail.ru> 2001-10-25 Andrew V. Samoilov <kai@cmail.ru>
@ -1204,13 +1213,13 @@
By David Kaelbling <drk@sgi.com>. By David Kaelbling <drk@sgi.com>.
http://bugzilla.gnome.org/show_bug.cgi?id=60933 http://bugzilla.gnome.org/show_bug.cgi?id=60933
* (cpio_read_oldc_head): Release name if mc_read fails. * (cpio_read_oldc_head): Release name if mc_read() fails.
2001-10-24 Andrew V. Samoilov <kai@cmail.ru> 2001-10-24 Andrew V. Samoilov <kai@cmail.ru>
* tcputil.c (rpc_get): Add missing va_end()s. * tcputil.c (rpc_get): Add missing va_end()s.
Fix memory leaking. Fix memory leaking.
* smbfs.h: Declare smbfs_set_debug. * smbfs.h: Declare smbfs_set_debug().
2001-10-20 Pavel Roskin <proski@gnu.org> 2001-10-20 Pavel Roskin <proski@gnu.org>
@ -1324,14 +1333,14 @@
2001-08-06 Andrew V. Samoilov <kai@cmail.ru> 2001-08-06 Andrew V. Samoilov <kai@cmail.ru>
* smbfs.c: Eliminate smbfs_get_free_bucket_init. convert_path * smbfs.c: Eliminate smbfs_get_free_bucket_init(). convert_path()
gives malloced filename, so this memory must be released after use. gives malloc()ed filename, so this memory must be released after use.
(reconnect): Fix segmentation fault. (reconnect): Fix segmentation fault.
(smbfs_loadddir): Don't g_strdup path. (smbfs_loadddir): Don't g_strdup() path.
(smbfs_get_free_bucket): Eliminate smbfs_get_free_bucket_init and (smbfs_get_free_bucket): Eliminate smbfs_get_free_bucket_init() and
smbfs_connections initialisation. smbfs_connections initialisation.
(smbfs_open_link): Likewise. Release host after get_master_browser. (smbfs_open_link): Likewise. Release host after get_master_browser().
(get_stat_info): Fix unneeded g_strdup/g_free calls. (get_stat_info): Fix unneeded g_strdup/g_free calls.
(smbfs_mkdir): Release path after use. (smbfs_mkdir): Release path after use.
(smbfs_mkdir): Likewise. (smbfs_mkdir): Likewise.
@ -1355,8 +1364,8 @@
* samba/libsmb/clientgen.c (cli_chkpath): Fix possible buffer overflow. * samba/libsmb/clientgen.c (cli_chkpath): Fix possible buffer overflow.
* smbfs.c (new_dir_entry): New function with repeated code from * smbfs.c (new_dir_entry): New function with repeated code from
browsing_helper, loaddir_helper and server_browsing_helper. browsing_helper(), loaddir_helper() and server_browsing_helper().
(browsing_helper): Use new_dir_entry. (browsing_helper): Use new_dir_entry().
(loaddir_helper): Likewise. (loaddir_helper): Likewise.
(server_browsing_helper): Likewise. (server_browsing_helper): Likewise.
@ -1519,8 +1528,9 @@
2001-06-01 Andrew V. Samoilov <sav@bcs.zp.ua> 2001-06-01 Andrew V. Samoilov <sav@bcs.zp.ua>
* ftpfs.h: Declare use_netrc, ftpfs_retry_seconds, ftpfs_first_cd_then_ls, * ftpfs.h: Declare use_netrc, ftpfs_retry_seconds,
ftpfs_use_passive_connections and ftpfs_use_unix_list_options. ftpfs_first_cd_then_ls, ftpfs_use_passive_connections and
ftpfs_use_unix_list_options.
* vfs.c [VFS_STANDALONE]: Undefine WITH_SMBFS, they are mutually * vfs.c [VFS_STANDALONE]: Undefine WITH_SMBFS, they are mutually
exclusive now. exclusive now.
@ -1572,8 +1582,8 @@
(loaddir_helper): Don't ignore hidden files, style fixes. (loaddir_helper): Don't ignore hidden files, style fixes.
(browsing_helper): typestr declared as char *, fstrcpy replaced by =. (browsing_helper): typestr declared as char *, fstrcpy replaced by =.
(do_connect): Call cli_shutdown () and authinfo_remove () if (do_connect): Call cli_shutdown() and authinfo_remove() if
cli_session_setup () fails. It is not good idea to remember cli_session_setup() fails. It is not good idea to remember
wrong username/password. wrong username/password.
(smbfs_free_dir): Nested between #ifdef SMBFS_FREE_DIR ... #endif. (smbfs_free_dir): Nested between #ifdef SMBFS_FREE_DIR ... #endif.
@ -1646,12 +1656,12 @@
2001-03-15 Andrew V. Samoilov <sav@bcs.zp.ua> 2001-03-15 Andrew V. Samoilov <sav@bcs.zp.ua>
* samba/libsmb/smbdes.c: undefine uchar before redefine it * samba/libsmb/smbdes.c: Undefine uchar before redefine it
* smbfs.c (smbfs_close): honour changed semantics for return value * smbfs.c (smbfs_close): Honour changed semantics for return value
(on error -1 is expected). (on error -1 is expected).
* (fs): it is at least strange use char * for counter. Changed to int * (fs): It is at least strange use char * for counter. Changed to int
2001-03-14 Pavel Roskin <proski@gnu.org> 2001-03-14 Pavel Roskin <proski@gnu.org>

Просмотреть файл

@ -1,14 +1,15 @@
/* Virtual File System: Midnight Commander file system. /* Virtual File System: Midnight Commander file system.
Copyright (C) 1995, 1996, 1997 The Free Software Foundation Copyright (C) 1995, 1996, 1997 The Free Software Foundation
Written by Wayne Roberts <wroberts1@home.com> Written by Wayne Roberts <wroberts1@home.com>, 1997
Andrew V. Samoilov <sav@bcs.zp.ua> 2002, 2003
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License modify it under the terms of the GNU Library General Public License
as published by the Free Software Foundation; either version 2 of as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version. the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@ -1737,53 +1738,44 @@ smbfs_setctl (vfs *me, char *path, int ctlop, char *arg)
return 0; return 0;
} }
static smbfs_handle *
open_write (smbfs_handle *remote_handle, char *rname, int flags, int mode)
{
if (flags & O_TRUNC) /* if it exists truncate to zero */
DEBUG(3, ("open_write: O_TRUNC\n"));
remote_handle->fnum = cli_open(remote_handle->cli, rname, flags, DENY_NONE);
if (remote_handle->fnum == -1) {
message_3s (1, MSG_ERROR, _(" %s opening remote file %s "),
cli_errstr(remote_handle->cli), CNV_LANG(rname));
DEBUG(1,("smbfs_open(rname:%s) error:%s\n",
rname, cli_errstr(remote_handle->cli)));
my_errno = cli_error(remote_handle->cli, NULL, &err, NULL);
return NULL;
}
return remote_handle;
}
static smbfs_handle * static smbfs_handle *
open_read (smbfs_handle *remote_handle, char *rname, int flags, int mode) open_readwrite (smbfs_handle *remote_handle, char *rname, int flags, int mode)
{ {
size_t size; size_t size;
remote_handle->fnum = if (flags & O_TRUNC) /* if it exists truncate to zero */
cli_open(remote_handle->cli, rname, O_RDONLY, DENY_NONE); DEBUG (3, ("smbfs_open: O_TRUNC\n"));
if (remote_handle->fnum == -1) { remote_handle->fnum =
message_3s (1, MSG_ERROR, _(" %s opening remote file %s "), cli_open (remote_handle->cli, rname, flags & O_CREAT ? flags : O_RDONLY,
cli_errstr(remote_handle->cli), CNV_LANG(rname)); DENY_NONE);
DEBUG(1,("smbfs_open(rname:%s) error:%s\n",
rname, cli_errstr(remote_handle->cli))); if (remote_handle->fnum == -1) {
my_errno = cli_error(remote_handle->cli, NULL, &err, NULL); message_3s (1, MSG_ERROR, _(" %s opening remote file %s "),
return NULL; cli_errstr (remote_handle->cli), CNV_LANG (rname));
} DEBUG (1, ("smbfs_open(rname:%s) error:%s\n",
rname, cli_errstr (remote_handle->cli)));
if (!cli_qfileinfo(remote_handle->cli, remote_handle->fnum, my_errno = cli_error (remote_handle->cli, NULL, &err, NULL);
&remote_handle->attr, &size, NULL, NULL, NULL, NULL, NULL) && return NULL;
!cli_getattrE(remote_handle->cli, remote_handle->fnum, }
&remote_handle->attr, &size, NULL, NULL, NULL)) {
message_2s (1, MSG_ERROR, " getattrib: %s ", if (flags & O_CREAT)
cli_errstr(remote_handle->cli)); return remote_handle;
DEBUG(1,("smbfs_open(rname:%s) getattrib:%s\n",
rname, cli_errstr(remote_handle->cli))); if (!cli_qfileinfo (remote_handle->cli, remote_handle->fnum,
my_errno = cli_error(remote_handle->cli, NULL, &err, NULL); &remote_handle->attr, &size, NULL, NULL, NULL, NULL,
return NULL; NULL)
&& !cli_getattrE (remote_handle->cli, remote_handle->fnum,
&remote_handle->attr, &size, NULL, NULL, NULL)) {
message_2s (1, MSG_ERROR, " getattrib: %s ",
cli_errstr (remote_handle->cli));
DEBUG (1,
("smbfs_open(rname:%s) getattrib:%s\n", rname,
cli_errstr (remote_handle->cli)));
my_errno = cli_error (remote_handle->cli, NULL, &err, NULL);
cli_close (remote_handle->cli, remote_handle->fnum);
return NULL;
} }
return remote_handle; return remote_handle;
@ -1797,25 +1789,24 @@ smbfs_open (vfs *me, char *file, int flags, int mode)
smbfs_connection *sc; smbfs_connection *sc;
smbfs_handle *remote_handle; smbfs_handle *remote_handle;
DEBUG(3, ("smbfs_open(file:%s, flags:%d, mode:%d)\n", file, flags, mode)); DEBUG(3, ("smbfs_open(file:%s, flags:%d, mode:%o)\n", file, flags, mode));
if (!(remote_file = smbfs_get_path (&sc, file))) if (!(remote_file = smbfs_get_path (&sc, file)))
return 0; return 0;
p = remote_file; p = remote_file;
convert_path(&remote_file, FALSE); convert_path (&remote_file, FALSE);
g_free (p); g_free (p);
remote_handle = g_new (smbfs_handle, 2); remote_handle = g_new (smbfs_handle, 2);
remote_handle->cli = sc->cli; remote_handle->cli = sc->cli;
remote_handle->nread = 0; remote_handle->nread = 0;
if (flags & O_CREAT) ret = open_readwrite (remote_handle, remote_file, flags, mode);
ret = open_write(remote_handle, remote_file, flags, mode);
else
ret = open_read(remote_handle, remote_file, flags, mode);
g_free (remote_file); g_free (remote_file);
if (!ret)
g_free (remote_handle);
return ret; return ret;
} }