Import ncpfs 0.3
This commit is contained in:
127
dir.c
127
dir.c
@@ -303,13 +303,34 @@ ncp_readdir(struct inode *inode, struct file *filp,
|
||||
}
|
||||
|
||||
static int
|
||||
ncp_read_volume_list(struct ncp_server *server, int start_with, int cache_size)
|
||||
ncp_read_volume_list(struct ncp_server *server, int fpos, int cache_size)
|
||||
{
|
||||
struct ncp_dirent *entry = c_entry;
|
||||
|
||||
int total_count = 0;
|
||||
int i;
|
||||
|
||||
void fill_one(char *name)
|
||||
{
|
||||
if (total_count < fpos) {
|
||||
DPRINTK("ncp_do_readdir: skipped file: %s\n", name);
|
||||
} else if (total_count >= fpos + cache_size) {
|
||||
return;
|
||||
} else {
|
||||
DPRINTK("ncp_do_readdir: found file: %s\n", name);
|
||||
|
||||
entry->attr = aDIR;
|
||||
entry->mtime = 0;
|
||||
entry->ctime = 0;
|
||||
entry->atime = 0;
|
||||
entry->size = 1024;
|
||||
entry->f_pos = total_count;
|
||||
strcpy(entry->path, name);
|
||||
entry += 1;
|
||||
}
|
||||
total_count += 1;
|
||||
}
|
||||
|
||||
for (i=0; i<NCP_NUMBER_OF_VOLUMES; i++) {
|
||||
|
||||
struct ncp_volume_info info;
|
||||
@@ -319,29 +340,12 @@ ncp_read_volume_list(struct ncp_server *server, int start_with, int cache_size)
|
||||
}
|
||||
|
||||
if (strlen(info.volume_name) > 0) {
|
||||
|
||||
if (total_count < start_with) {
|
||||
DPRINTK("ncp_read_volumes: skipped vol: %s\n",
|
||||
info.volume_name);
|
||||
} else if (total_count >= start_with + cache_size) {
|
||||
return (total_count - start_with);
|
||||
} else {
|
||||
DPRINTK("ncp_read_volumes: found vol %s\n",
|
||||
info.volume_name);
|
||||
entry->attr = aDIR;
|
||||
entry->mtime = 0;
|
||||
entry->ctime = 0;
|
||||
entry->atime = 0;
|
||||
entry->size = 1024;
|
||||
entry->f_pos = total_count;
|
||||
strcpy(entry->path, info.volume_name);
|
||||
entry += 1;
|
||||
}
|
||||
|
||||
total_count += 1;
|
||||
fill_one(info.volume_name);
|
||||
}
|
||||
}
|
||||
return (total_count - start_with);
|
||||
fill_one(".");
|
||||
fill_one("..");
|
||||
return (total_count - fpos);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -353,6 +357,41 @@ ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos,
|
||||
|
||||
int total_count = 0;
|
||||
|
||||
void fill_one(int attr, char *name,
|
||||
int upd_time, int upd_date,
|
||||
int cr_date, int ac_date, int length)
|
||||
{
|
||||
if (total_count < fpos) {
|
||||
DPRINTK("ncp_do_readdir: skipped file: %s\n", name);
|
||||
} else if (total_count >= fpos + cache_size) {
|
||||
return;
|
||||
} else {
|
||||
DPRINTK("ncp_do_readdir: found file: %s\n", name);
|
||||
|
||||
entry->attr = attr;
|
||||
if ((attr & aDIR) == 0) {
|
||||
entry->mtime = date_dos2unix(upd_time,
|
||||
upd_date);
|
||||
entry->ctime = date_dos2unix(0, cr_date);
|
||||
entry->atime = date_dos2unix(0, ac_date);
|
||||
entry->size = length;
|
||||
} else {
|
||||
/* Sorry, I do not know how to get the
|
||||
* values for directories :-(. Mail
|
||||
* lendecke@namu01.gwdg.de if you
|
||||
* know more. */
|
||||
entry->mtime = 0;
|
||||
entry->ctime = 0;
|
||||
entry->atime = 0;
|
||||
entry->size = 1024;
|
||||
}
|
||||
entry->f_pos = total_count;
|
||||
strcpy(entry->path, name);
|
||||
entry += 1;
|
||||
}
|
||||
total_count += 1;
|
||||
}
|
||||
|
||||
void doit(int attr) {
|
||||
|
||||
if (ncp_file_search_init(server, 0, NCP_FINFO(dir)->path,
|
||||
@@ -363,35 +402,20 @@ ncp_do_readdir(struct ncp_server *server, struct inode *dir, int fpos,
|
||||
|
||||
while (ncp_file_search_continue(server, &fsinfo, attr, "*",
|
||||
&finfo) == 0) {
|
||||
|
||||
fill_one(attr, finfo.file_name,
|
||||
finfo.update_time, finfo.update_date,
|
||||
finfo.creation_date, finfo.access_date,
|
||||
finfo.file_length);
|
||||
|
||||
if (total_count < fpos) {
|
||||
DPRINTK("ncp_do_readdir: skipped file: %s\n",
|
||||
finfo.file_name);
|
||||
} else if (total_count >= fpos + cache_size) {
|
||||
return;
|
||||
} else {
|
||||
DPRINTK("ncp_do_readdir: found file: %s\n",
|
||||
finfo.file_name);
|
||||
|
||||
entry->attr = attr;
|
||||
entry->mtime =
|
||||
date_dos2unix(finfo.update_time,
|
||||
finfo.update_date);
|
||||
entry->ctime =
|
||||
date_dos2unix(0, finfo.creation_date);
|
||||
entry->atime =
|
||||
date_dos2unix(0, finfo.access_date);
|
||||
entry->size = (attr & aDIR) != 0 ?
|
||||
1024 : finfo.file_length;
|
||||
entry->f_pos = total_count;
|
||||
strcpy(entry->path, finfo.file_name);
|
||||
entry += 1;
|
||||
}
|
||||
total_count += 1;
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
fill_one(aDIR, ".", 0, 0, 0, 0, 0);
|
||||
fill_one(aDIR, "..", 0, 0, 0, 0, 0);
|
||||
|
||||
doit(0);
|
||||
doit(aDIR);
|
||||
|
||||
@@ -480,7 +504,7 @@ get_pname_static(struct inode *dir, const char *name, int len,
|
||||
/* We're at the top */
|
||||
|
||||
path[0] = '\0';
|
||||
*res_len = 1;
|
||||
*res_len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -497,7 +521,6 @@ get_pname_static(struct inode *dir, const char *name, int len,
|
||||
path[len] = '\0';
|
||||
}
|
||||
else if (parentlen == 0) {
|
||||
|
||||
memcpy(path, name, len);
|
||||
path[len] = ':';
|
||||
path[len+1] = '\0';
|
||||
@@ -787,10 +810,10 @@ ncp_lookup(struct inode *dir, const char *__name, int len,
|
||||
i, c_entry[i].path);
|
||||
if (strcmp(c_entry[i].path, __name) == 0) {
|
||||
DPRINTK("ncp_lookup: found in cache!\n");
|
||||
finfo = c_entry[i];
|
||||
finfo.path = NULL; /* It's not ours! */
|
||||
found_in_cache = 1;
|
||||
break;
|
||||
finfo = c_entry[i];
|
||||
finfo.path = NULL; /* It's not ours! */
|
||||
found_in_cache = 1;
|
||||
break;
|
||||
}
|
||||
i = (i + 1) % c_size;
|
||||
DDPRINTK("ncp_lookup: index %d, name %s failed\n",
|
||||
|
||||
Reference in New Issue
Block a user