mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* extfs.c (s_readdir): Simplify.
* direntry.c (vfs_s_readdir): Use vfs_dirent. * mcfs.c (mcfs_readdir): Likewise. * smbfs.c (smbfs_readdir): Likewise. * undelfs.c (undelfs_readdir): Use vfs_dirent and compute_namelen().
This commit is contained in:
parent
37f335b8c0
commit
cf8ab0de99
@ -1,5 +1,12 @@
|
||||
2002-08-15 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* extfs.c (s_readdir): Simplify.
|
||||
* direntry.c (vfs_s_readdir): Use vfs_dirent.
|
||||
* mcfs.c (mcfs_readdir): Likewise.
|
||||
* smbfs.c (smbfs_readdir): Likewise.
|
||||
* undelfs.c (undelfs_readdir): Use vfs_dirent and
|
||||
compute_namelen().
|
||||
|
||||
* vfs.h: Introduce union vfs_dirent to ensure that we have
|
||||
enough space for the filename.
|
||||
* extfs.c (s_readdir): Use vfs_dirent. Avoid strcpy().
|
||||
|
@ -613,29 +613,25 @@ vfs_s_opendir (vfs *me, char *dirname)
|
||||
}
|
||||
|
||||
void *
|
||||
vfs_s_readdir (void *data)
|
||||
vfs_s_readdir(void *data)
|
||||
{
|
||||
static struct {
|
||||
struct dirent dir;
|
||||
#ifdef NEED_EXTRA_DIRENT_BUFFER
|
||||
char extra_buffer [MC_MAXPATHLEN];
|
||||
#endif
|
||||
} dir;
|
||||
|
||||
static union vfs_dirent dir;
|
||||
struct dirhandle *info = (struct dirhandle *) data;
|
||||
|
||||
if (!(info->cur))
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
if (info->cur->name)
|
||||
strcpy (&(dir.dir.d_name [0]), info->cur->name);
|
||||
else
|
||||
vfs_die ("Null in structure-can not happen");
|
||||
if (info->cur->name) {
|
||||
strncpy(dir.dent.d_name, info->cur->name, MC_MAXPATHLEN);
|
||||
dir.dent.d_name[MC_MAXPATHLEN] = 0;
|
||||
} else {
|
||||
vfs_die("Null in structure-can not happen");
|
||||
}
|
||||
|
||||
compute_namelen(&dir.dir);
|
||||
compute_namelen(&dir.dent);
|
||||
info->cur = info->cur->next;
|
||||
|
||||
return (void *)&dir;
|
||||
|
||||
return (void *) &dir;
|
||||
}
|
||||
|
||||
int
|
||||
|
18
vfs/extfs.c
18
vfs/extfs.c
@ -880,25 +880,21 @@ static void * s_opendir (vfs *me, char *dirname)
|
||||
return info;
|
||||
}
|
||||
|
||||
static void * s_readdir (void *data)
|
||||
static void * s_readdir(void *data)
|
||||
{
|
||||
static union vfs_dirent dir;
|
||||
int namelen;
|
||||
|
||||
struct entry **info = (struct entry **) data;
|
||||
|
||||
if (!*info)
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
namelen = min (strlen ((*info)->name), MC_MAXPATHLEN);
|
||||
strncpy(dir.dent.d_name, (*info)->name, MC_MAXPATHLEN);
|
||||
dir.dent.d_name[MC_MAXPATHLEN] = 0;
|
||||
|
||||
strncpy (dir.dent.d_name, (*info)->name, namelen);
|
||||
dir.dent.d_name[namelen] = 0;
|
||||
|
||||
compute_namelen (&dir.dent);
|
||||
compute_namelen(&dir.dent);
|
||||
*info = (*info)->next_in_dir;
|
||||
|
||||
return (void *)&dir;
|
||||
|
||||
return (void *) &dir;
|
||||
}
|
||||
|
||||
static int s_telldir (void *data)
|
||||
|
32
vfs/mcfs.c
32
vfs/mcfs.c
@ -710,46 +710,38 @@ static void mcfs_free_dir (dir_entry *de)
|
||||
g_free (de);
|
||||
}
|
||||
|
||||
/* Explanation:
|
||||
* On some operating systems (Slowaris 2 for example)
|
||||
* the d_name member is just a char long (Nice trick that break everything,
|
||||
* so we need to set up some space for the filename.
|
||||
*/
|
||||
static struct {
|
||||
struct dirent dent;
|
||||
#ifdef NEED_EXTRA_DIRENT_BUFFER
|
||||
char extra_buffer [MC_MAXPATHLEN];
|
||||
#endif
|
||||
} mcfs_readdir_data;
|
||||
static union vfs_dirent mcfs_readdir_data;
|
||||
|
||||
/* The readdir routine loads the complete directory */
|
||||
/* It's too slow to ask the server each time */
|
||||
/* It now also sends the complete lstat information for each file */
|
||||
static struct stat *cached_lstat_info;
|
||||
static void *mcfs_readdir (void *info)
|
||||
|
||||
static void *mcfs_readdir(void *info)
|
||||
{
|
||||
opendir_info *mcfs_info;
|
||||
opendir_info *mcfs_info;
|
||||
char *dirent_dest;
|
||||
|
||||
mcfs_info = (opendir_info *) info;
|
||||
|
||||
if (!mcfs_info->entries)
|
||||
if (!mcfs_loaddir (mcfs_info))
|
||||
if (!mcfs_loaddir(mcfs_info))
|
||||
return NULL;
|
||||
|
||||
if (mcfs_info->current == 0){
|
||||
if (mcfs_info->current == 0) {
|
||||
cached_lstat_info = 0;
|
||||
mcfs_free_dir (mcfs_info->entries);
|
||||
mcfs_free_dir(mcfs_info->entries);
|
||||
mcfs_info->entries = 0;
|
||||
return NULL;
|
||||
}
|
||||
dirent_dest = &(mcfs_readdir_data.dent.d_name [0]);
|
||||
strcpy (dirent_dest, mcfs_info->current->text);
|
||||
dirent_dest = mcfs_readdir_data.dent.d_name;
|
||||
strncpy(dirent_dest, mcfs_info->current->text, MC_MAXPATHLEN);
|
||||
dirent_dest[MC_MAXPATHLEN] = 0;
|
||||
cached_lstat_info = &mcfs_info->current->my_stat;
|
||||
mcfs_info->current = mcfs_info->current->next;
|
||||
|
||||
compute_namelen (&mcfs_readdir_data.dent);
|
||||
|
||||
compute_namelen(&mcfs_readdir_data.dent);
|
||||
|
||||
return &mcfs_readdir_data;
|
||||
}
|
||||
|
||||
|
38
vfs/smbfs.c
38
vfs/smbfs.c
@ -720,48 +720,38 @@ smbfs_free_dir (dir_entry *de)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Explanation:
|
||||
* On some operating systems (Slowaris 2 for example)
|
||||
* the d_name member is just a char long (Nice trick that break everything,
|
||||
* so we need to set up some space for the filename.
|
||||
*/
|
||||
static struct {
|
||||
struct dirent dent;
|
||||
#ifdef NEED_EXTRA_DIRENT_BUFFER
|
||||
char extra_buffer [MC_MAXPATHLEN];
|
||||
#endif
|
||||
} smbfs_readdir_data;
|
||||
|
||||
|
||||
/* The readdir routine loads the complete directory */
|
||||
/* It's too slow to ask the server each time */
|
||||
/* It now also sends the complete lstat information for each file */
|
||||
static void *
|
||||
smbfs_readdir (void *info)
|
||||
smbfs_readdir(void *info)
|
||||
{
|
||||
static char * const dirent_dest = &(smbfs_readdir_data.dent.d_name [0]);
|
||||
opendir_info *smbfs_info = (opendir_info *) info;
|
||||
static union vfs_dirent smbfs_readdir_data;
|
||||
static char *const dirent_dest = smbfs_readdir_data.dent.d_name;
|
||||
opendir_info *smbfs_info = (opendir_info *) info;
|
||||
|
||||
DEBUG(4, ("smbfs_readdir(%s)\n", smbfs_info->dirname));
|
||||
|
||||
|
||||
if (!smbfs_info->entries)
|
||||
if (!smbfs_loaddir (smbfs_info))
|
||||
return NULL;
|
||||
if (!smbfs_loaddir(smbfs_info))
|
||||
return NULL;
|
||||
|
||||
if (smbfs_info->current == 0) { /* reached end of dir entries */
|
||||
DEBUG(3, ("smbfs_readdir: smbfs_info->current = 0\n"));
|
||||
DEBUG(3, ("smbfs_readdir: smbfs_info->current = 0\n"));
|
||||
#ifdef SMBFS_FREE_DIR
|
||||
smbfs_free_dir (smbfs_info->entries);
|
||||
smbfs_info->entries = 0;
|
||||
smbfs_free_dir(smbfs_info->entries);
|
||||
smbfs_info->entries = 0;
|
||||
#endif
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
pstrcpy (dirent_dest, smbfs_info->current->text);
|
||||
strncpy(dirent_dest, smbfs_info->current->text, MC_MAXPATHLEN);
|
||||
dirent_dest[MC_MAXPATHLEN] = 0;
|
||||
smbfs_info->current = smbfs_info->current->next;
|
||||
|
||||
compute_namelen(&smbfs_readdir_data.dent);
|
||||
|
||||
return &smbfs_readdir_data;
|
||||
return &smbfs_readdir_data;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -319,41 +319,31 @@ quit_opendir:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Explanation:
|
||||
* On some operating systems (Slowaris 2 for example)
|
||||
* the d_name member is just a char long (Nice trick that break everything,
|
||||
* so we need to set up some space for the filename.
|
||||
*/
|
||||
static struct {
|
||||
struct dirent dent;
|
||||
#ifdef NEED_EXTRA_DIRENT_BUFFER
|
||||
char extra_buffer [MC_MAXPATHLEN];
|
||||
#endif
|
||||
} undelfs_readdir_data;
|
||||
|
||||
static void *
|
||||
undelfs_readdir (void *vfs_info)
|
||||
undelfs_readdir(void *vfs_info)
|
||||
{
|
||||
static union vfs_dirent undelfs_readdir_data;
|
||||
char *dirent_dest;
|
||||
|
||||
if (vfs_info != fs){
|
||||
message_1s (1, undelfserr, _(" vfs_info is not fs! "));
|
||||
|
||||
if (vfs_info != fs) {
|
||||
message_1s(1, undelfserr, _(" vfs_info is not fs! "));
|
||||
return NULL;
|
||||
}
|
||||
if (readdir_ptr == num_delarray)
|
||||
return NULL;
|
||||
dirent_dest = (char *) &(undelfs_readdir_data.dent.d_name [0]);
|
||||
dirent_dest = undelfs_readdir_data.dent.d_name;
|
||||
if (readdir_ptr < 0)
|
||||
g_snprintf(dirent_dest, MC_MAXPATHLEN, "%s", readdir_ptr == -2 ? "." : "..");
|
||||
g_snprintf(dirent_dest, MC_MAXPATHLEN, "%s",
|
||||
readdir_ptr == -2 ? "." : "..");
|
||||
else
|
||||
g_snprintf(dirent_dest, MC_MAXPATHLEN, "%ld:%d",
|
||||
(long)delarray [readdir_ptr].ino,
|
||||
delarray [readdir_ptr].num_blocks);
|
||||
(long) delarray[readdir_ptr].ino,
|
||||
delarray[readdir_ptr].num_blocks);
|
||||
readdir_ptr++;
|
||||
|
||||
#if 0
|
||||
undelfs_readdir_data.dent.d_namlen = strlen (undelfs_readdir_data.dent.d_name);
|
||||
#endif
|
||||
|
||||
compute_namelen(&undelfs_readdir_data.dent);
|
||||
|
||||
return &undelfs_readdir_data;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user