1
1

* vfs.h: Constify some arguments for many functions.

* xdirentry.h: Likewise.  Adjust all dependencies.
Этот коммит содержится в:
Pavel Roskin 2003-10-28 02:10:33 +00:00
родитель 5bc20fd294
Коммит 7d16d65e35
15 изменённых файлов: 245 добавлений и 189 удалений

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

@ -1,5 +1,8 @@
2003-10-27 Pavel Roskin <proski@gnu.org>
* vfs.h: Constify some arguments for many functions.
* xdirentry.h: Likewise. Adjust all dependencies.
* *.c: Rename functions that don't have an a prefix indicating
what file they are defined in. This simplifies debugging.

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

@ -129,42 +129,44 @@ static void cpio_free_archive(struct vfs_class *me, struct vfs_s_super *super)
mc_close(super->u.arch.fd);
}
static int cpio_open_cpio_file(struct vfs_class *me, struct vfs_s_super *super, char *name)
static int
cpio_open_cpio_file (struct vfs_class *me, struct vfs_s_super *super,
const char *name)
{
int fd, type;
mode_t mode;
struct vfs_s_inode *root;
if((fd = mc_open(name, O_RDONLY)) == -1) {
if ((fd = mc_open (name, O_RDONLY)) == -1) {
message (1, MSG_ERROR, _("Cannot open cpio archive\n%s"), name);
return -1;
}
super->name = g_strdup(name);
super->u.arch.fd = -1; /* for now */
mc_stat(name, &(super->u.arch.st));
super->name = g_strdup (name);
super->u.arch.fd = -1; /* for now */
mc_stat (name, &(super->u.arch.st));
super->u.arch.type = CPIO_UNKNOWN;
type = get_compression_type(fd);
type = get_compression_type (fd);
if (type != COMPRESSION_NONE) {
char *s;
mc_close(fd);
s = g_strconcat(name, decompress_extension(type), NULL);
if((fd = mc_open(s, O_RDONLY)) == -1) {
mc_close (fd);
s = g_strconcat (name, decompress_extension (type), NULL);
if ((fd = mc_open (s, O_RDONLY)) == -1) {
message (1, MSG_ERROR, _("Cannot open cpio archive\n%s"), s);
g_free(s);
g_free (s);
return -1;
}
g_free(s);
g_free (s);
}
super->u.arch.fd = fd;
mode = super->u.arch.st.st_mode & 07777;
mode |= (mode & 0444) >> 2; /* set eXec where Read is */
mode |= (mode & 0444) >> 2; /* set eXec where Read is */
mode |= S_IFDIR;
root = vfs_s_new_inode(me, super, &(super->u.arch.st));
root = vfs_s_new_inode (me, super, &(super->u.arch.st));
root->st.st_mode = mode;
root->data_offset = -1;
root->st.st_nlink++;
@ -172,7 +174,7 @@ static int cpio_open_cpio_file(struct vfs_class *me, struct vfs_s_super *super,
super->root = root;
CPIO_SEEK_SET(super, 0);
CPIO_SEEK_SET (super, 0);
return fd;
}
@ -505,17 +507,19 @@ cpio_create_entry (struct vfs_class *me, struct vfs_s_super *super,
/* Need to CPIO_SEEK_CUR to skip the file at the end of add entry!!!! */
static int cpio_open_archive(struct vfs_class *me, struct vfs_s_super *super, char *name, char *op)
static int
cpio_open_archive (struct vfs_class *me, struct vfs_s_super *super,
const char *name, char *op)
{
int status = STATUS_START;
if(cpio_open_cpio_file(me, super, name) == -1)
if (cpio_open_cpio_file (me, super, name) == -1)
return -1;
for(;;) {
status = cpio_read_head(me, super);
for (;;) {
status = cpio_read_head (me, super);
switch(status) {
switch (status) {
case STATUS_EOF:
message (1, MSG_ERROR, _("Unexpected end of file\n%s"), name);
return 0;
@ -531,17 +535,18 @@ static int cpio_open_archive(struct vfs_class *me, struct vfs_s_super *super, ch
}
/* Remaining functions are exactly same as for tarfs (and were in fact just copied) */
static void *cpio_super_check(struct vfs_class *me, char *archive_name, char *op)
static void *
cpio_super_check (struct vfs_class *me, const char *archive_name, char *op)
{
static struct stat sb;
if(mc_stat(archive_name, &sb))
if (mc_stat (archive_name, &sb))
return NULL;
return &sb;
}
static int
cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc, char *archive_name,
char *op, void *cookie)
cpio_super_same (struct vfs_class *me, struct vfs_s_super *parc,
const char *archive_name, char *op, void *cookie)
{
struct stat *archive_stat = cookie; /* stat of main archive */

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

@ -420,13 +420,14 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
/* ------------------------------------------------------------------------= */
static void
vfs_s_stamp_me (struct vfs_class *me, struct vfs_s_super *psup, char *fs_name)
vfs_s_stamp_me (struct vfs_class *me, struct vfs_s_super *psup,
const char *fs_name)
{
struct vfs_stamping *parent;
struct vfs_class *v;
v = vfs_get_class (fs_name);
if (v->flags & VFSF_LOCAL){
if (v->flags & VFSF_LOCAL) {
parent = NULL;
} else {
parent = g_new (struct vfs_stamping, 1);
@ -438,27 +439,33 @@ vfs_s_stamp_me (struct vfs_class *me, struct vfs_s_super *psup, char *fs_name)
}
char *
vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **archive, int flags)
vfs_s_get_path_mangle (struct vfs_class *me, const char *inname,
struct vfs_s_super **archive, int flags)
{
char *local, *op, *archive_name;
char *local, *op;
const char *archive_name;
int result = -1;
struct vfs_s_super *super;
void *cookie = NULL;
archive_name = inname;
vfs_split (inname, &local, &op);
if (!local)
local = "";
local = "";
if (MEDATA->archive_check)
if (! (cookie = MEDATA->archive_check (me, archive_name, op)))
if (!(cookie = MEDATA->archive_check (me, archive_name, op)))
return NULL;
for (super = MEDATA->supers; super != NULL; super = super->next){
int i; /* 0 == other, 1 == same, return it, 2 == other but stop scanning */
if ((i = MEDATA->archive_same (me, super, archive_name, op, cookie))){
if (i==1) goto return_success;
else break;
for (super = MEDATA->supers; super != NULL; super = super->next) {
/* 0 == other, 1 == same, return it, 2 == other but stop scanning */
int i;
if ((i =
MEDATA->archive_same (me, super, archive_name, op, cookie))) {
if (i == 1)
goto return_success;
else
break;
}
}
@ -467,7 +474,7 @@ vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **
super = vfs_s_new_super (me);
result = MEDATA->open_archive (me, super, archive_name, op);
if (result == -1){
if (result == -1) {
vfs_s_free_super (me, super);
ERRNOR (EIO, NULL);
}
@ -479,7 +486,7 @@ vfs_s_get_path_mangle (struct vfs_class *me, char *inname, struct vfs_s_super **
vfs_s_insert_super (me, super);
vfs_s_stamp_me (me, super, archive_name);
return_success:
return_success:
*archive = super;
return local;
}
@ -536,7 +543,7 @@ vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino)
/* ------------------------ readdir & friends ----------------------------- */
static struct vfs_s_inode *
vfs_s_inode_from_path (struct vfs_class *me, char *name, int flags)
vfs_s_inode_from_path (struct vfs_class *me, const char *name, int flags)
{
struct vfs_s_super *super;
struct vfs_s_inode *ino;
@ -684,7 +691,7 @@ vfs_s_readlink (struct vfs_class *me, char *path, char *buf, int size)
}
static void *
vfs_s_open (struct vfs_class *me, char *file, int flags, int mode)
vfs_s_open (struct vfs_class *me, const char *file, int flags, int mode)
{
int was_changed = 0;
struct vfs_s_fh *fh;
@ -697,7 +704,7 @@ vfs_s_open (struct vfs_class *me, char *file, int flags, int mode)
ino = vfs_s_find_inode (me, super, q, LINK_FOLLOW, FL_NONE);
if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
ERRNOR (EEXIST, NULL);
if (!ino){
if (!ino) {
char *dirname, *name, *save;
struct vfs_s_entry *ent;
struct vfs_s_inode *dir;
@ -724,7 +731,7 @@ vfs_s_open (struct vfs_class *me, char *file, int flags, int mode)
if (S_ISDIR (ino->st.st_mode))
ERRNOR (EISDIR, NULL);
fh = g_new (struct vfs_s_fh, 1);
fh->pos = 0;
fh->ino = ino;
@ -732,28 +739,29 @@ vfs_s_open (struct vfs_class *me, char *file, int flags, int mode)
fh->changed = was_changed;
fh->linear = 0;
if (IS_LINEAR(flags)) {
if (IS_LINEAR (flags)) {
if (MEDATA->linear_start) {
print_vfs_message (_("Starting linear transfer..."));
if (!MEDATA->linear_start (me, fh, 0)){
g_free(fh);
if (!MEDATA->linear_start (me, fh, 0)) {
g_free (fh);
return NULL;
}
}
} else if ((MEDATA->fh_open) && (MEDATA->fh_open (me, fh, flags, mode))){
g_free(fh);
return NULL;
}
} else if ((MEDATA->fh_open)
&& (MEDATA->fh_open (me, fh, flags, mode))) {
g_free (fh);
return NULL;
}
if (fh->ino->localname){
fh->handle = open (fh->ino->localname, NO_LINEAR(flags), mode);
if (fh->handle == -1){
g_free(fh);
if (fh->ino->localname) {
fh->handle = open (fh->ino->localname, NO_LINEAR (flags), mode);
if (fh->handle == -1) {
g_free (fh);
ERRNOR (errno, NULL);
}
}
/* i.e. we had no open files and now we have one */
/* i.e. we had no open files and now we have one */
vfs_rmstamp (me, (vfsid) super, 1);
super->fd_usage++;
fh->ino->st.st_nlink++;
@ -959,16 +967,13 @@ vfs_s_ferrno (struct vfs_class *me)
}
static char *
vfs_s_getlocalcopy (struct vfs_class *me, char *path)
vfs_s_getlocalcopy (struct vfs_class *me, const char *path)
{
struct vfs_s_inode *ino;
char buf[MC_MAXPATHLEN];
strncpy (buf, path, MC_MAXPATHLEN);
ino = vfs_s_inode_from_path (me, path, FL_FOLLOW | FL_NONE);
if (!ino->localname)
ino->localname = mc_def_getlocalcopy (me, buf);
ino->localname = mc_def_getlocalcopy (me, path);
/* FIXME: fd_usage++ missing */
return g_strdup (ino->localname);
}

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

@ -199,7 +199,7 @@ static void extfs_free_archive (struct archive *archive)
}
static FILE *
extfs_open_archive (int fstype, char *name, struct archive **pparc)
extfs_open_archive (int fstype, const char *name, struct archive **pparc)
{
static dev_t __extfs_no = 0;
FILE *result;
@ -242,7 +242,7 @@ extfs_open_archive (int fstype, char *name, struct archive **pparc)
current_archive = g_new (struct archive, 1);
current_archive->fstype = fstype;
current_archive->name = name ? g_strdup (name) : name;
current_archive->name = name ? g_strdup (name) : NULL;
current_archive->local_name = local_name;
if (local_name != NULL)
@ -279,16 +279,17 @@ extfs_open_archive (int fstype, char *name, struct archive **pparc)
* Return 0 on success, -1 on error.
*/
static int
extfs_read_archive (int fstype, char *name, struct archive **pparc)
extfs_read_archive (int fstype, const char *name, struct archive **pparc)
{
FILE *extfsd;
char *buffer;
struct archive *current_archive;
char *current_file_name, *current_link_name;
if ((extfsd = extfs_open_archive (fstype, name, &current_archive)) == NULL) {
if ((extfsd =
extfs_open_archive (fstype, name, &current_archive)) == NULL) {
message (1, MSG_ERROR, _("Cannot open %s archive\n%s"),
extfs_prefixes[fstype], name);
extfs_prefixes[fstype], name);
return -1;
}
@ -320,7 +321,9 @@ extfs_read_archive (int fstype, char *name, struct archive **pparc)
if (S_ISDIR (hstat.st_mode)
&& (!strcmp (p, ".") || !strcmp (p, "..")))
goto read_extfs_continue;
pent = extfs_find_entry (current_archive->root_entry, q, 1, 0);
pent =
extfs_find_entry (current_archive->root_entry, q, 1,
0);
if (pent == NULL) {
/* FIXME: Should clean everything one day */
g_free (buffer);
@ -341,7 +344,7 @@ extfs_read_archive (int fstype, char *name, struct archive **pparc)
if (!S_ISLNK (hstat.st_mode) && current_link_name != NULL) {
pent =
extfs_find_entry (current_archive->root_entry,
current_link_name, 0, 0);
current_link_name, 0, 0);
if (pent == NULL) {
/* FIXME: Should clean everything one day */
g_free (buffer);
@ -412,10 +415,11 @@ extfs_read_archive (int fstype, char *name, struct archive **pparc)
* mangled by this operation (so you must not free its return value).
*/
static char *
extfs_get_path_mangle (char *inname, struct archive **archive, int is_dir,
int do_not_open)
extfs_get_path_mangle (const char *inname, struct archive **archive,
int is_dir, int do_not_open)
{
char *local, *archive_name, *op;
char *local, *op;
const char *archive_name;
int result = -1;
struct archive *parc;
struct vfs_stamping *parent;
@ -448,7 +452,9 @@ extfs_get_path_mangle (char *inname, struct archive **archive, int is_dir,
}
}
result = do_not_open ? -1 : extfs_read_archive (fstype, archive_name, &parc);
result =
do_not_open ? -1 : extfs_read_archive (fstype, archive_name,
&parc);
if (result == -1)
ERRNOR (EIO, NULL);
@ -642,7 +648,7 @@ extfs_run (char *file)
}
static void *
extfs_open (struct vfs_class *me, char *file, int flags, int mode)
extfs_open (struct vfs_class *me, const char *file, int flags, int mode)
{
struct pseudofile *extfs_info;
struct archive *archive;
@ -1228,17 +1234,18 @@ static void extfs_free (vfsid id)
extfs_free_archive (archive);
}
static char *extfs_getlocalcopy (struct vfs_class *me, char *path)
static char *
extfs_getlocalcopy (struct vfs_class *me, const char *path)
{
struct pseudofile *fp =
(struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
struct pseudofile *fp =
(struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
char *p;
if (fp == NULL)
return NULL;
return NULL;
if (fp->entry->inode->local_filename == NULL) {
extfs_close ((void *) fp);
return NULL;
extfs_close ((void *) fp);
return NULL;
}
p = g_strdup (fp->entry->inode->local_filename);
fp->archive->fd_usage++;
@ -1246,22 +1253,24 @@ static char *extfs_getlocalcopy (struct vfs_class *me, char *path)
return p;
}
static int extfs_ungetlocalcopy (struct vfs_class *me, char *path, char *local, int has_changed)
static int
extfs_ungetlocalcopy (struct vfs_class *me, const char *path, char *local,
int has_changed)
{
struct pseudofile *fp =
(struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
struct pseudofile *fp =
(struct pseudofile *) extfs_open (me, path, O_RDONLY, 0);
if (fp == NULL)
return 0;
return 0;
if (!strcmp (fp->entry->inode->local_filename, local)) {
fp->archive->fd_usage--;
fp->has_changed |= has_changed;
extfs_close ((void *) fp);
return 0;
fp->archive->fd_usage--;
fp->has_changed |= has_changed;
extfs_close ((void *) fp);
return 0;
} else {
/* Should not happen */
extfs_close ((void *) fp);
return mc_def_ungetlocalcopy (me, path, local, has_changed);
/* Should not happen */
extfs_close ((void *) fp);
return mc_def_ungetlocalcopy (me, path, local, has_changed);
}
}

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

@ -306,12 +306,14 @@ fish_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
}
static int
fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op)
fish_open_archive (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op)
{
char *host, *user, *password, *p;
int flags;
p = vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, &password, 0, URL_NOSLASH);
p = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags,
&password, 0, URL_NOSLASH);
if (p)
g_free (p);
@ -319,7 +321,7 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archiv
SUP.host = host;
SUP.user = user;
SUP.flags = flags;
if (!strncmp( op, "rsh:", 4 ))
if (!strncmp (op, "rsh:", 4))
SUP.flags |= FISH_FLAG_RSH;
SUP.cwdir = NULL;
if (password)
@ -328,19 +330,20 @@ fish_open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archiv
}
static int
fish_archive_same(struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op, void *cookie)
{
fish_archive_same (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op, void *cookie)
{
char *host, *user;
int flags;
op = vfs_split_url (strchr(op, ':')+1, &host, &user, &flags, 0, 0, URL_NOSLASH);
op = vfs_split_url (strchr (op, ':') + 1, &host, &user, &flags, 0, 0,
URL_NOSLASH);
if (op)
g_free (op);
flags = ((strcmp (host, SUP.host) == 0) &&
(strcmp (user, SUP.user) == 0) &&
(flags == SUP.flags));
flags = ((strcmp (host, SUP.host) == 0)
&& (strcmp (user, SUP.user) == 0) && (flags == SUP.flags));
g_free (host);
g_free (user);

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

@ -741,7 +741,8 @@ ftpfs_open_archive_int (struct vfs_class *me, struct vfs_s_super *super)
}
static int
ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archive_name, char *op)
ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super,
const char *archive_name, char *op)
{
char *host, *user, *password;
int port;
@ -760,15 +761,17 @@ ftpfs_open_archive (struct vfs_class *me, struct vfs_s_super *super, char *archi
SUP.strict = ftpfs_use_unix_list_options ? RFC_AUTODETECT : RFC_STRICT;
SUP.isbinary = TYPE_UNKNOWN;
SUP.remote_is_amiga = 0;
super->name = g_strdup("/");
super->root = vfs_s_new_inode (me, super, vfs_s_default_stat(me, S_IFDIR | 0755));
super->name = g_strdup ("/");
super->root =
vfs_s_new_inode (me, super,
vfs_s_default_stat (me, S_IFDIR | 0755));
return ftpfs_open_archive_int (me, super);
}
static int
ftpfs_archive_same (struct vfs_class *me, struct vfs_s_super *super,
char *archive_name, char *op, void *cookie)
const char *archive_name, char *op, void *cookie)
{
char *host, *user;
int port;

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

@ -19,18 +19,18 @@
static struct vfs_class vfs_local_ops;
static void *
local_open (struct vfs_class *me, char *file, int flags, int mode)
local_open (struct vfs_class *me, const char *file, int flags, int mode)
{
int *local_info;
int fd;
fd = open (file, NO_LINEAR(flags), mode);
fd = open (file, NO_LINEAR (flags), mode);
if (fd == -1)
return 0;
local_info = g_new (int, 1);
*local_info = fd;
return local_info;
}
@ -249,13 +249,14 @@ local_free (vfsid id)
}
static char *
local_getlocalcopy (struct vfs_class *me, char *path)
local_getlocalcopy (struct vfs_class *me, const char *path)
{
return g_strdup (path);
}
static int
local_ungetlocalcopy (struct vfs_class *me, char *path, char *local, int has_changed)
local_ungetlocalcopy (struct vfs_class *me, const char *path, char *local,
int has_changed)
{
return 0;
}

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

@ -83,7 +83,7 @@ static struct vfs_class vfs_mcfs_ops;
/* Extract the hostname and username from the path */
/* path is in the form: hostname:user/remote-dir */
static char *
mcfs_get_host_and_username (char *path, char **host, char **user,
mcfs_get_host_and_username (const char *path, char **host, char **user,
int *port, char **pass)
{
return vfs_split_url (path, host, user, port, pass, 0, 0);
@ -361,7 +361,7 @@ mcfs_set_error (int result, int errno_num)
}
static char *
mcfs_get_path (mcfs_connection **mc, char *path)
mcfs_get_path (mcfs_connection **mc, const char *path)
{
char *user, *host, *remote_path;
char *pass;
@ -510,7 +510,7 @@ mcfs_gethome (mcfs_connection *mc)
/* The callbacks */
static void *
mcfs_open (struct vfs_class *me, char *file, int flags, int mode)
mcfs_open (struct vfs_class *me, const char *file, int flags, int mode)
{
char *remote_file;
mcfs_connection *mc;
@ -520,8 +520,8 @@ mcfs_open (struct vfs_class *me, char *file, int flags, int mode)
if (!(remote_file = mcfs_get_path (&mc, file)))
return 0;
rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file,
RPC_INT, flags, RPC_INT, mode, RPC_END);
rpc_send (mc->sock, RPC_INT, MC_OPEN, RPC_STRING, remote_file, RPC_INT,
flags, RPC_INT, mode, RPC_END);
g_free (remote_file);
if (0 ==

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

@ -43,46 +43,58 @@ static int sfs_flags[ MAXFS ];
#define F_NOLOCALCOPY 4
#define F_FULLMATCH 8
static int sfs_uptodate (char *name, char *cache)
static int
sfs_uptodate (char *name, char *cache)
{
return 1;
}
static int sfs_vfmake (struct vfs_class *me, char *name, char *cache)
static int
sfs_vfmake (struct vfs_class *me, const char *name, char *cache)
{
char *inpath, *op;
int w;
char pad [10240];
char pad[10240];
char *s, *t = pad;
int was_percent = 0;
vfs_split (name, &inpath, &op);
if ((w = (*me->which) (me, op)) == -1)
vfs_die ("This cannot happen... Hopefully.\n");
vfs_die ("This cannot happen... Hopefully.\n");
if ((sfs_flags[w] & F_1) || (!strcmp (name, "/"))) ; else return -1;
if ((sfs_flags[w] & F_1) || (!strcmp (name, "/")));
else
return -1;
/* if ((sfs_flags[w] & F_2) || (!inpath) || (!*inpath)); else return -1; */
if (!(sfs_flags[w] & F_NOLOCALCOPY)) {
s = mc_getlocalcopy (name);
s = mc_getlocalcopy (name);
if (!s)
return -1;
name = name_quote (s, 0);
name = name_quote (s, 0);
g_free (s);
} else
name = name_quote (name, 0);
#define COPY_CHAR if (t-pad>sizeof(pad)) { g_free (name); return -1; } else *t++ = *s;
#define COPY_STRING(a) if ((t-pad)+strlen(a)>sizeof(pad)) { g_free (name); return -1; } else { strcpy (t, a); t+= strlen(a); }
} else
name = name_quote (name, 0);
#define COPY_CHAR if (t-pad>sizeof(pad)) { return -1; } else *t++ = *s;
#define COPY_STRING(a) if ((t-pad)+strlen(a)>sizeof(pad)) { return -1; } else { strcpy (t, a); t+= strlen(a); }
for (s = sfs_command[w]; *s; s++) {
if (was_percent) {
if (was_percent) {
char *ptr = NULL;
const char *ptr = NULL;
was_percent = 0;
switch (*s) {
case '1': ptr = name; break;
case '2': ptr = op + strlen (sfs_prefix[w]); break;
case '3': ptr = cache; break;
case '%': COPY_CHAR; continue;
case '1':
ptr = name;
break;
case '2':
ptr = op + strlen (sfs_prefix[w]);
break;
case '3':
ptr = cache;
break;
case '%':
COPY_CHAR;
continue;
}
COPY_STRING (ptr);
} else {
@ -92,7 +104,6 @@ static int sfs_vfmake (struct vfs_class *me, char *name, char *cache)
COPY_CHAR;
}
}
g_free (name);
open_error_pipe ();
if (my_system (EXECUTE_AS_SHELL, "/bin/sh", pad)) {
@ -101,11 +112,11 @@ static int sfs_vfmake (struct vfs_class *me, char *name, char *cache)
}
close_error_pipe (0, NULL);
return 0; /* OK */
return 0; /* OK */
}
static char *
sfs_redirect (struct vfs_class *me, char *name)
sfs_redirect (struct vfs_class *me, const char *name)
{
struct cachedfile *cur = head;
char *cache;
@ -146,19 +157,19 @@ sfs_redirect (struct vfs_class *me, char *name)
}
static void *
sfs_open (struct vfs_class *me, char *path, int flags, int mode)
sfs_open (struct vfs_class *me, const char *path, int flags, int mode)
{
int *sfs_info;
int fd;
path = sfs_redirect (me, path);
fd = open (path, NO_LINEAR(flags), mode);
fd = open (path, NO_LINEAR (flags), mode);
if (fd == -1)
return 0;
sfs_info = g_new (int, 1);
*sfs_info = fd;
return sfs_info;
}
@ -282,15 +293,18 @@ static int sfs_nothingisopen (vfsid id)
return 1;
}
static char *sfs_getlocalcopy (struct vfs_class *me, char *path)
static char *
sfs_getlocalcopy (struct vfs_class *me, const char *path)
{
path = sfs_redirect (me, path);
return g_strdup (path);
}
static int sfs_ungetlocalcopy (struct vfs_class *me, char *path, char *local, int has_changed)
static int
sfs_ungetlocalcopy (struct vfs_class *me, const char *path, char *local,
int has_changed)
{
g_free(local);
g_free (local);
return 0;
}

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

@ -1791,7 +1791,7 @@ smbfs_open_readwrite (smbfs_handle *remote_handle, char *rname, int flags, int m
}
static void *
smbfs_open (struct vfs_class *me, char *file, int flags, int mode)
smbfs_open (struct vfs_class *me, const char *file, int flags, int mode)
{
char *remote_file, *p;
void *ret;

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

@ -198,18 +198,20 @@ static void tar_free_archive (struct vfs_class *me, struct vfs_s_super *archive)
static int current_tar_position = 0;
/* Returns fd of the open tar file */
static int tar_tar_open_archive (struct vfs_class *me, char *name, struct vfs_s_super *archive)
static int
tar_open_archive_int (struct vfs_class *me, const char *name,
struct vfs_s_super *archive)
{
int result, type;
mode_t mode;
struct vfs_s_inode *root;
result = mc_open (name, O_RDONLY);
if (result == -1) {
message (1, MSG_ERROR, _("Cannot open tar archive\n%s"), name);
message (1, MSG_ERROR, _("Cannot open tar archive\n%s"), name);
ERRNOR (ENOENT, -1);
}
archive->name = g_strdup (name);
mc_stat (name, &(archive->u.arch.st));
archive->u.arch.fd = -1;
@ -219,21 +221,24 @@ static int tar_tar_open_archive (struct vfs_class *me, char *name, struct vfs_s_
mc_lseek (result, 0, SEEK_SET);
if (type != COMPRESSION_NONE) {
char *s;
mc_close( result );
s = g_strconcat ( archive->name, decompress_extension (type), NULL );
mc_close (result);
s = g_strconcat (archive->name, decompress_extension (type), NULL);
result = mc_open (s, O_RDONLY);
if (result == -1)
if (result == -1)
message (1, MSG_ERROR, _("Cannot open tar archive\n%s"), s);
g_free(s);
g_free (s);
if (result == -1)
ERRNOR (ENOENT, -1);
}
archive->u.arch.fd = result;
mode = archive->u.arch.st.st_mode & 07777;
if (mode & 0400) mode |= 0100;
if (mode & 0040) mode |= 0010;
if (mode & 0004) mode |= 0001;
if (mode & 0400)
mode |= 0100;
if (mode & 0040)
mode |= 0010;
if (mode & 0004)
mode |= 0001;
mode |= S_IFDIR;
root = vfs_s_new_inode (me, archive, &archive->u.arch.st);
@ -514,7 +519,7 @@ tar_read_header (struct vfs_class *me, struct vfs_s_super *archive, int tard)
*/
static int
tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive,
char *name, char *op)
const char *name, char *op)
{
/* Initial status at start of archive */
ReadStatus status = STATUS_EOFMARK;
@ -523,7 +528,7 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive,
current_tar_position = 0;
/* Open for reading */
if ((tard = tar_tar_open_archive (me, name, archive)) == -1)
if ((tard = tar_open_archive_int (me, name, archive)) == -1)
return -1;
for (;;) {
@ -580,7 +585,8 @@ tar_open_archive (struct vfs_class *me, struct vfs_s_super *archive,
return 0;
}
static void *tar_super_check(struct vfs_class *me, char *archive_name, char *op)
static void *
tar_super_check (struct vfs_class *me, const char *archive_name, char *op)
{
static struct stat stat_buf;
if (mc_stat (archive_name, &stat_buf))
@ -589,8 +595,8 @@ static void *tar_super_check(struct vfs_class *me, char *archive_name, char *op)
}
static int
tar_super_same (struct vfs_class *me, struct vfs_s_super *parc, char *archive_name,
char *op, void *cookie)
tar_super_same (struct vfs_class *me, struct vfs_s_super *parc,
const char *archive_name, char *op, void *cookie)
{
struct stat *archive_stat = cookie; /* stat of main archive */

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

@ -380,19 +380,20 @@ typedef struct {
/* We do not support lseek */
static void *
undelfs_open (struct vfs_class *me, char *fname, int flags, int mode)
undelfs_open (struct vfs_class *me, const char *fname, int flags, int mode)
{
char *file, *f;
ext2_ino_t inode, i;
ext2_ino_t inode, i;
undelfs_file *p = NULL;
/* Only allow reads on this file system */
undelfs_get_path (fname, &file, &f);
if (!file)
return 0;
if (!ext2_fname || strcmp (ext2_fname, file)){
message (1, undelfserr, _(" You have to chdir to extract files first "));
if (!ext2_fname || strcmp (ext2_fname, file)) {
message (1, undelfserr,
_(" You have to chdir to extract files first "));
g_free (file);
g_free (f);
return 0;
@ -400,19 +401,19 @@ undelfs_open (struct vfs_class *me, char *fname, int flags, int mode)
inode = atol (f);
/* Search the file into delarray */
for (i = 0; i < num_delarray; i++){
if (inode != delarray [i].ino)
for (i = 0; i < num_delarray; i++) {
if (inode != delarray[i].ino)
continue;
/* Found: setup all the structures needed by read */
p = g_new (undelfs_file, 1);
if (!p){
if (!p) {
g_free (file);
g_free (f);
return 0;
}
p->buf = g_malloc (fs->blocksize);
if (!p->buf){
if (!p->buf) {
g_free (p);
g_free (file);
g_free (f);
@ -423,7 +424,7 @@ undelfs_open (struct vfs_class *me, char *fname, int flags, int mode)
p->f_index = i;
p->error_code = 0;
p->pos = 0;
p->size = delarray [i].size;
p->size = delarray[i].size;
}
g_free (file);
g_free (f);

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

@ -1008,9 +1008,10 @@ mc_munmap (caddr_t addr, size_t len)
#endif
char *
mc_def_getlocalcopy (struct vfs_class *vfs, char *filename)
mc_def_getlocalcopy (struct vfs_class *vfs, const char *filename)
{
char *tmp, *suffix, *basename;
char *tmp, *suffix;
const char *basename;
int fdin, fdout, i;
char buffer[8192];
struct stat mystat;
@ -1079,8 +1080,8 @@ mc_getlocalcopy (const char *pathname)
}
int
mc_def_ungetlocalcopy (struct vfs_class *vfs, char *filename, char *local,
int has_changed)
mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename,
char *local, int has_changed)
{
int fdin = -1, fdout = -1, i;
if (has_changed) {

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

@ -34,7 +34,8 @@ struct vfs_class {
int (*which) (struct vfs_class *me, char *path);
void *(*open) (struct vfs_class *me, char *fname, int flags, int mode);
void *(*open) (struct vfs_class *me, const char *fname, int flags,
int mode);
int (*close) (void *vfs_info);
int (*read) (void *vfs_info, char *buffer, int count);
int (*write) (void *vfs_info, char *buf, int count);
@ -49,9 +50,11 @@ struct vfs_class {
int (*chmod) (struct vfs_class *me, char *path, int mode);
int (*chown) (struct vfs_class *me, char *path, int owner, int group);
int (*utime) (struct vfs_class *me, char *path, struct utimbuf * times);
int (*utime) (struct vfs_class *me, char *path,
struct utimbuf * times);
int (*readlink) (struct vfs_class *me, char *path, char *buf, int size);
int (*readlink) (struct vfs_class *me, char *path, char *buf,
int size);
int (*symlink) (struct vfs_class *me, char *n1, char *n2);
int (*link) (struct vfs_class *me, char *p1, char *p2);
int (*unlink) (struct vfs_class *me, char *path);
@ -67,19 +70,21 @@ struct vfs_class {
int (*nothingisopen) (vfsid id);
void (*free) (vfsid id);
char *(*getlocalcopy) (struct vfs_class *me, char *filename);
int (*ungetlocalcopy) (struct vfs_class *me, char *filename, char *local,
int has_changed);
char *(*getlocalcopy) (struct vfs_class *me, const char *filename);
int (*ungetlocalcopy) (struct vfs_class *me, const char *filename,
char *local, int has_changed);
int (*mkdir) (struct vfs_class *me, char *path, mode_t mode);
int (*rmdir) (struct vfs_class *me, char *path);
int (*ctl) (void *vfs_info, int ctlop, void *arg);
int (*setctl) (struct vfs_class *me, char *path, int ctlop, void *arg);
int (*setctl) (struct vfs_class *me, char *path, int ctlop,
void *arg);
#ifdef HAVE_MMAP
caddr_t (*mmap) (struct vfs_class *me, caddr_t addr, size_t len, int prot,
int flags, void *vfs_info, off_t offset);
int (*munmap) (struct vfs_class *me, caddr_t addr, size_t len, void *vfs_info);
caddr_t (*mmap) (struct vfs_class *me, caddr_t addr, size_t len,
int prot, int flags, void *vfs_info, off_t offset);
int (*munmap) (struct vfs_class *me, caddr_t addr, size_t len,
void *vfs_info);
#endif
};
@ -175,9 +180,9 @@ int mc_mkdir (char *path, mode_t mode);
char *mc_getlocalcopy (const char *pathname);
int mc_ungetlocalcopy (const char *pathname, char *local, int has_changed);
char *mc_def_getlocalcopy (struct vfs_class *vfs, char *filename);
int mc_def_ungetlocalcopy (struct vfs_class *vfs, char *filename, char *local,
int has_changed);
char *mc_def_getlocalcopy (struct vfs_class *vfs, const char *filename);
int mc_def_ungetlocalcopy (struct vfs_class *vfs, const char *filename,
char *local, int has_changed);
int mc_ctl (int fd, int ctlop, void *arg);
int mc_setctl (char *path, int ctlop, void *arg);
#ifdef HAVE_MMAP

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

@ -121,11 +121,11 @@ struct vfs_s_subclass {
void (*free_inode) (struct vfs_class *me, struct vfs_s_inode *ino); /* optional */
int (*init_entry) (struct vfs_class *me, struct vfs_s_entry *entry); /* optional */
void *(*archive_check) (struct vfs_class *me, char *name, char *op); /* optional */
void *(*archive_check) (struct vfs_class *me, const char *name, char *op); /* optional */
int (*archive_same) (struct vfs_class *me, struct vfs_s_super *psup,
char *archive_name, char *op, void *cookie);
const char *archive_name, char *op, void *cookie);
int (*open_archive) (struct vfs_class *me, struct vfs_s_super *psup,
char *archive_name, char *op);
const char *archive_name, char *op);
void (*free_archive) (struct vfs_class *me,
struct vfs_s_super *psup);
@ -180,7 +180,7 @@ struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me,
/* outside interface */
void vfs_s_init_class (struct vfs_class *vclass);
char *vfs_s_get_path_mangle (struct vfs_class *me, char *inname,
char *vfs_s_get_path_mangle (struct vfs_class *me, const char *inname,
struct vfs_s_super **archive, int flags);
void vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super);
char *vfs_s_fullpath (struct vfs_class *me, struct vfs_s_inode *ino);