* smbfs.c (statfile_helper): Merge with loaddir_helper().

(get_remote_stat): Use loaddir_helper().  Care about
single_entry instead of eliminated statfile_helper().
This commit is contained in:
Andrew V. Samoilov 2002-09-12 06:25:21 +00:00
parent 39fb489652
commit 14c3f90d2f
2 changed files with 33 additions and 58 deletions

View File

@ -1,5 +1,9 @@
2002-09-11 Andrew V. Samoilov <sav@bcs.zp.ua>
* smbfs.c (statfile_helper): Merge with loaddir_helper().
(get_remote_stat): Use loaddir_helper(). Care about
single_entry instead of eliminated statfile_helper().
* samba/libsmb/clientgen.c (cli_NetServerEnum): Add void*
parameter to (*fn)() and void *state parameter.
(cli_list): Likewise.

View File

@ -454,12 +454,13 @@ browsing_helper (const char *name, uint32 type, const char *comment, void *state
static void
loaddir_helper (file_info * finfo, const char *mask, void *entry)
{
dir_entry *new_entry;
dir_entry *new_entry = (dir_entry *) entry;
time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
#if 0 /* I want to see dot files */
if (finfo->mode & aHIDDEN)
return; /* don't bother with hidden files, "~$" screws up mc */
#endif
if (!entry)
new_entry = new_dir_entry (finfo->name);
new_entry->my_stat.st_size = finfo->size;
@ -469,12 +470,12 @@ loaddir_helper (file_info * finfo, const char *mask, void *entry)
new_entry->my_stat.st_uid = finfo->uid;
new_entry->my_stat.st_gid = finfo->gid;
new_entry->my_stat.st_mode =
new_entry->my_stat.st_mode = /* rw-rw-rw */
S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH;
/* if (finfo->mode & aVOLID); nothing similar in real world */
if (finfo->mode & aDIR)
new_entry->my_stat.st_mode |=
new_entry->my_stat.st_mode |= /* drwxrwxrwx */
S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
else
new_entry->my_stat.st_mode |= S_IFREG; /* if not dir, regular file? */
@ -484,10 +485,11 @@ loaddir_helper (file_info * finfo, const char *mask, void *entry)
if (finfo->mode & aRONLY)
new_entry->my_stat.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
DEBUG (3, (" %-30s%7.7s%8.0f %s",
DEBUG (entry ? 3 : 6, (" %-30s%7.7s%8.0f %s",
CNV_LANG (finfo->name),
attrib_string (finfo->mode),
(double) finfo->size, asctime (LocalTime (&t))));
(double) finfo->size,
asctime (LocalTime (&t))));
}
/* takes "/foo/bar/file" and gives malloced "\\foo\\bar\\file" */
@ -1263,10 +1265,16 @@ fake_share_stat(const char *server_url, const char *path, struct stat *buf)
/* stat a single file, get_remote_stat callback */
static dir_entry *single_entry;
static void
statfile_helper (file_info * finfo, const char *mask, void * entry)
/* stat a single file */
static int
get_remote_stat (smbfs_connection * sc, char *path, struct stat *buf)
{
time_t t = finfo->mtime; /* the time is assumed to be passed as GMT */
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
char *mypath = path;
DEBUG (3, ("get_remote_stat(): mypath:%s\n", mypath));
convert_path (&mypath, FALSE);
#if 0 /* single_entry is never free()d now. And only my_stat is used */
single_entry = g_new (dir_entry, 1);
@ -1278,51 +1286,14 @@ statfile_helper (file_info * finfo, const char *mask, void * entry)
if (!single_entry)
single_entry = g_new0 (dir_entry, 1);
single_entry->my_stat.st_size = finfo->size;
single_entry->my_stat.st_mtime = finfo->mtime;
single_entry->my_stat.st_atime = finfo->atime;
single_entry->my_stat.st_ctime = finfo->ctime;
single_entry->my_stat.st_uid = finfo->uid;
single_entry->my_stat.st_gid = finfo->gid;
single_entry->my_stat.st_mode = /* rw-rw-rw */
S_IRUSR | S_IRGRP | S_IROTH | S_IWUSR | S_IWGRP | S_IWOTH;
/* if (finfo->mode & aVOLID); nothing similar in real world */
if (finfo->mode & aDIR) /* drwxrwxrwx */
single_entry->my_stat.st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
else /* if not dir, regular file? */
single_entry->my_stat.st_mode |= S_IFREG;
/* if (finfo->mode & aARCH); DOS archive */
/* if (finfo->mode & aHIDDEN); like a dot file? */
/* if (finfo->mode & aSYSTEM); like a kernel? */
if (finfo->mode & aRONLY)
single_entry->my_stat.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
DEBUG (6, (" %-30s%7.7s%8.0f %s",
CNV_LANG (finfo->name),
attrib_string (finfo->mode),
(double) finfo->size, asctime (LocalTime (&t))));
}
/* stat a single file */
static int
get_remote_stat(smbfs_connection *sc, char *path, struct stat *buf)
{
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
char *mypath = path;
DEBUG(3, ("get_remote_stat(): mypath:%s\n", mypath));
convert_path(&mypath, FALSE);
if (cli_list(sc->cli, mypath, attribute, statfile_helper, &single_entry) < 1) {
if (cli_list
(sc->cli, mypath, attribute, loaddir_helper, single_entry) < 1) {
my_errno = ENOENT;
g_free (mypath);
return -1; /* cli_list returns number of files */
}
memcpy(buf, &single_entry->my_stat, sizeof(struct stat));
memcpy (buf, &single_entry->my_stat, sizeof (struct stat));
/* don't free here, use for smbfs_fstat() */
/* g_free(single_entry->text);