* cpio.c (cpio_ungetlocalcopy): Remove.
* tar.c (tar_ungetlocalcopy): Likewise. * vfs.c (mc_def_ungetlocalcopy): Add support for read-only filesystems.
Этот коммит содержится в:
родитель
0e71b37f2a
Коммит
4ee3f26133
@ -1,3 +1,10 @@
|
|||||||
|
2003-10-27 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* cpio.c (cpio_ungetlocalcopy): Remove.
|
||||||
|
* tar.c (tar_ungetlocalcopy): Likewise.
|
||||||
|
* vfs.c (mc_def_ungetlocalcopy): Add support for read-only
|
||||||
|
filesystems.
|
||||||
|
|
||||||
2003-10-26 Pavel Roskin <proski@gnu.org>
|
2003-10-26 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
* direntry.c (vfs_s_find_inode): Only allow search from root.
|
* direntry.c (vfs_s_find_inode): Only allow search from root.
|
||||||
|
@ -571,13 +571,6 @@ static int cpio_read(void *fh, char *buffer, int count)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cpio_ungetlocalcopy(struct vfs_class *me, char *path, char *local, int has_changed)
|
|
||||||
{
|
|
||||||
/* We do just nothing. (We are read only and do not need to free local,
|
|
||||||
since it will be freed when tar archive will be freed */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int cpio_fh_open(struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
|
static int cpio_fh_open(struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
|
||||||
{
|
{
|
||||||
if ((flags & O_ACCMODE) != O_RDONLY) ERRNOR (EROFS, -1);
|
if ((flags & O_ACCMODE) != O_RDONLY) ERRNOR (EROFS, -1);
|
||||||
@ -603,6 +596,5 @@ init_cpiofs (void)
|
|||||||
vfs_cpiofs_ops.read = cpio_read;
|
vfs_cpiofs_ops.read = cpio_read;
|
||||||
vfs_cpiofs_ops.write = NULL;
|
vfs_cpiofs_ops.write = NULL;
|
||||||
vfs_cpiofs_ops.setctl = NULL;
|
vfs_cpiofs_ops.setctl = NULL;
|
||||||
vfs_cpiofs_ops.ungetlocalcopy = cpio_ungetlocalcopy;
|
|
||||||
vfs_register_class (&vfs_cpiofs_ops);
|
vfs_register_class (&vfs_cpiofs_ops);
|
||||||
}
|
}
|
||||||
|
@ -607,14 +607,6 @@ static int tar_read (void *fh, char *buffer, int count)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tar_ungetlocalcopy (struct vfs_class *me, char *path, char *local, int has_changed)
|
|
||||||
{
|
|
||||||
/* We do just nothing. (We are read only and do not need to free local,
|
|
||||||
since it will be freed when tar archive will be freed */
|
|
||||||
/* We have to report error if file has changed */
|
|
||||||
ERRNOR (EROFS, -has_changed);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tar_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
|
static int tar_fh_open (struct vfs_class *me, struct vfs_s_fh *fh, int flags, int mode)
|
||||||
{
|
{
|
||||||
if ((flags & O_ACCMODE) != O_RDONLY) ERRNOR (EROFS, -1);
|
if ((flags & O_ACCMODE) != O_RDONLY) ERRNOR (EROFS, -1);
|
||||||
@ -639,7 +631,6 @@ init_tarfs (void)
|
|||||||
vfs_tarfs_ops.data = &tarfs_subclass;
|
vfs_tarfs_ops.data = &tarfs_subclass;
|
||||||
vfs_tarfs_ops.read = tar_read;
|
vfs_tarfs_ops.read = tar_read;
|
||||||
vfs_tarfs_ops.write = NULL;
|
vfs_tarfs_ops.write = NULL;
|
||||||
vfs_tarfs_ops.ungetlocalcopy = tar_ungetlocalcopy;
|
|
||||||
vfs_tarfs_ops.setctl = NULL;
|
vfs_tarfs_ops.setctl = NULL;
|
||||||
vfs_register_class (&vfs_tarfs_ops);
|
vfs_register_class (&vfs_tarfs_ops);
|
||||||
}
|
}
|
||||||
|
24
vfs/vfs.c
24
vfs/vfs.c
@ -1079,11 +1079,15 @@ mc_getlocalcopy (const char *pathname)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mc_def_ungetlocalcopy (struct vfs_class *vfs, char *filename, char *local, int has_changed)
|
mc_def_ungetlocalcopy (struct vfs_class *vfs, char *filename, char *local,
|
||||||
{ /* Dijkstra probably hates me... But he should teach me how to do this nicely. */
|
int has_changed)
|
||||||
|
{
|
||||||
int fdin = -1, fdout = -1, i;
|
int fdin = -1, fdout = -1, i;
|
||||||
if (has_changed){
|
if (has_changed) {
|
||||||
char buffer [8192];
|
char buffer[8192];
|
||||||
|
|
||||||
|
if (!vfs->write)
|
||||||
|
goto failed;
|
||||||
|
|
||||||
fdin = open (local, O_RDONLY);
|
fdin = open (local, O_RDONLY);
|
||||||
if (fdin == -1)
|
if (fdin == -1)
|
||||||
@ -1091,19 +1095,19 @@ mc_def_ungetlocalcopy (struct vfs_class *vfs, char *filename, char *local, int h
|
|||||||
fdout = mc_open (filename, O_WRONLY | O_TRUNC);
|
fdout = mc_open (filename, O_WRONLY | O_TRUNC);
|
||||||
if (fdout == -1)
|
if (fdout == -1)
|
||||||
goto failed;
|
goto failed;
|
||||||
while ((i = read (fdin, buffer, sizeof (buffer))) > 0){
|
while ((i = read (fdin, buffer, sizeof (buffer))) > 0) {
|
||||||
if (mc_write (fdout, buffer, i) != i)
|
if (mc_write (fdout, buffer, i) != i)
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
goto failed;
|
goto failed;
|
||||||
|
|
||||||
if (close (fdin)==-1) {
|
if (close (fdin) == -1) {
|
||||||
fdin = -1;
|
fdin = -1;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
fdin = -1;
|
fdin = -1;
|
||||||
if (mc_close (fdout)==-1) {
|
if (mc_close (fdout) == -1) {
|
||||||
fdout = -1;
|
fdout = -1;
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
@ -1114,8 +1118,10 @@ mc_def_ungetlocalcopy (struct vfs_class *vfs, char *filename, char *local, int h
|
|||||||
|
|
||||||
failed:
|
failed:
|
||||||
message (1, _("Changes to file lost"), filename);
|
message (1, _("Changes to file lost"), filename);
|
||||||
if (fdout!=-1) mc_close(fdout);
|
if (fdout != -1)
|
||||||
if (fdin!=-1) close(fdin);
|
mc_close (fdout);
|
||||||
|
if (fdin != -1)
|
||||||
|
close (fdin);
|
||||||
unlink (local);
|
unlink (local);
|
||||||
g_free (local);
|
g_free (local);
|
||||||
return -1;
|
return -1;
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user