Removed function vfs_s_get_path(); Function vfs_s_get_path_mangle() renamed to vfs_s_get_path()

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2011-06-19 13:32:07 +03:00
parent 1beaecdf12
commit 60123b7c99
6 changed files with 40 additions and 55 deletions

View File

@ -13,7 +13,7 @@ TESTS = \
vfs_path_string_convert \
vfs_prefix_to_class \
vfs_split \
vfs_s_get_path_mangle
vfs_s_get_path
check_PROGRAMS = $(TESTS)
@ -35,5 +35,5 @@ vfs_prefix_to_class_SOURCES = \
vfs_path_string_convert_SOURCES = \
vfs_path_string_convert.c
vfs_s_get_path_mangle_SOURCES = \
vfs_s_get_path_mangle.c
vfs_s_get_path_SOURCES = \
vfs_s_get_path.c

View File

@ -1,4 +1,4 @@
/* lib/vfs - test vfs_s_get_path_mangle() function
/* lib/vfs - test vfs_s_get_path() function
Copyright (C) 2011 Free Software Foundation, Inc.
@ -120,14 +120,14 @@ vfs_die (const char *m)
/* --------------------------------------------------------------------------------------------- */
START_TEST (test_vfs_s_get_path_mangle)
START_TEST (test_vfs_s_get_path)
{
struct vfs_s_super *archive;
const char *result;
vfs_path_t *vpath = vfs_path_from_str("/" ETALON_VFS_NAME ARCH_NAME "#test1:/" ETALON_PATH);
result = vfs_s_get_path_mangle (vpath, &archive, 0);
result = vfs_s_get_path (vpath, &archive, 0);
fail_unless(strcmp(ETALON_PATH, result) == 0,
"expected(%s) doesn't equal to actual(%s)", ETALON_PATH, result);
@ -154,12 +154,12 @@ main (void)
tcase_add_checked_fixture (tc_core, setup, teardown);
/* Add new tests here: *************** */
tcase_add_test (tc_core, test_vfs_s_get_path_mangle);
tcase_add_test (tc_core, test_vfs_s_get_path);
/* *********************************** */
suite_add_tcase (s, tc_core);
sr = srunner_create (s);
srunner_set_log (sr, "vfs_s_get_path_mangle.log");
srunner_set_log (sr, "vfs_s_get_path.log");
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);

View File

@ -391,18 +391,6 @@ vfs_s_free_super (struct vfs_class *me, struct vfs_s_super *super)
g_free (super);
}
/* --------------------------------------------------------------------------------------------- */
/**
* Dissect the path and create corresponding superblock.
* The result should be freed.
*/
static char *
vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flags)
{
return g_strdup (vfs_s_get_path_mangle (vpath, archive, flags));
}
/* --------------------------------------------------------------------------------------------- */
/* Support of archives */
/* ------------------------ readdir & friends ----------------------------- */
@ -412,7 +400,7 @@ vfs_s_inode_from_path (const vfs_path_t * vpath, int flags)
{
struct vfs_s_super *super;
struct vfs_s_inode *ino;
char *q;
const char *q;
vfs_path_element_t *path_element;
q = vfs_s_get_path (vpath, &super, 0);
@ -430,7 +418,6 @@ vfs_s_inode_from_path (const vfs_path_t * vpath, int flags)
vfs_s_find_inode (path_element->class, super, q,
flags & FL_FOLLOW ? LINK_FOLLOW :
LINK_NO_FOLLOW, FL_DIR | (flags & ~FL_FOLLOW));
g_free (q);
return ino;
}
@ -855,12 +842,12 @@ static vfsid
vfs_s_getid (const vfs_path_t * vpath)
{
struct vfs_s_super *archive = NULL;
char *p;
const char *p;
p = vfs_s_get_path (vpath, &archive, FL_NO_OPEN);
if (p == NULL)
return NULL;
g_free (p);
return (vfsid) archive;
}
@ -1042,13 +1029,17 @@ vfs_s_find_inode (struct vfs_class *me, const struct vfs_s_super *super,
/* --------------------------------------------------------------------------------------------- */
/* Ook, these were functions around directory entries / inodes */
/* -------------------------------- superblock games -------------------------- */
/*
* Dissect the path and create corresponding superblock. Note that inname
* can be changed and the result may point inside the original string.
/**
* get path from last VFS-element and create corresponding superblock
*
* @param vpath source path object
* @param archive pointer to object for store newly created superblock
* @param flags flags
*
* @return path from last VFS-element
*/
const char *
vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive, int flags)
vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive, int flags)
{
GList *iter;
const char *retval;
@ -1177,7 +1168,7 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
int was_changed = 0;
vfs_file_handler_t *fh;
struct vfs_s_super *super;
char *q;
const char *q;
struct vfs_s_inode *ino;
vfs_path_element_t *path_element;
@ -1189,29 +1180,26 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
ino = vfs_s_find_inode (path_element->class, super, q, LINK_FOLLOW, FL_NONE);
if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)))
{
g_free (q);
path_element->class->verrno = EEXIST;
return NULL;
}
if (!ino)
{
char *dirname, *name, *save;
char *dirname, *name, *save, *q_mangle;
struct vfs_s_entry *ent;
struct vfs_s_inode *dir;
int tmp_handle;
/* If the filesystem is read-only, disable file creation */
if (!(flags & O_CREAT) || !(path_element->class->write))
{
g_free (q);
return NULL;
}
split_dir_name (path_element->class, q, &dirname, &name, &save);
q_mangle = g_strdup (q);
split_dir_name (path_element->class, q_mangle, &dirname, &name, &save);
dir = vfs_s_find_inode (path_element->class, super, dirname, LINK_FOLLOW, FL_DIR);
if (dir == NULL)
{
g_free (q);
g_free (q_mangle);
return NULL;
}
if (save)
@ -1220,17 +1208,14 @@ vfs_s_open (const vfs_path_t * vpath, int flags, mode_t mode)
ino = ent->ino;
vfs_s_insert_entry (path_element->class, dir, ent);
tmp_handle = vfs_mkstemps (&ino->localname, path_element->class->name, name);
g_free (q_mangle);
if (tmp_handle == -1)
{
g_free (q);
return NULL;
}
close (tmp_handle);
was_changed = 1;
}
g_free (q);
if (S_ISDIR (ino->st.st_mode))
{
path_element->class->verrno = EISDIR;

View File

@ -168,7 +168,7 @@ struct vfs_s_inode *vfs_s_find_root (struct vfs_class *me, struct vfs_s_entry *e
/* outside interface */
void vfs_s_init_class (struct vfs_class *vclass, struct vfs_s_subclass *sub);
const char *vfs_s_get_path_mangle (const vfs_path_t * vpath, struct vfs_s_super **archive,
const char *vfs_s_get_path (const vfs_path_t * vpath, struct vfs_s_super **archive,
int flags);
void vfs_s_invalidate (struct vfs_class *me, struct vfs_s_super *super);

View File

@ -1171,11 +1171,11 @@ fish_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
struct vfs_s_super *super, *super2;
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath1, -1);
crpath1 = vfs_s_get_path_mangle (vpath1, &super, 0);
crpath1 = vfs_s_get_path (vpath1, &super, 0);
if (crpath1 == NULL)
return -1;
crpath2 = vfs_s_get_path_mangle (vpath2, &super2, 0);
crpath2 = vfs_s_get_path (vpath2, &super2, 0);
if (crpath2 == NULL)
return -1;
@ -1205,11 +1205,11 @@ fish_link (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
path_element = vfs_path_get_by_index (vpath1, -1);
crpath1 = vfs_s_get_path_mangle (vpath1, &super, 0);
crpath1 = vfs_s_get_path (vpath1, &super, 0);
if (crpath1 == NULL)
return -1;
crpath2 = vfs_s_get_path_mangle (vpath2, &super2, 0);
crpath2 = vfs_s_get_path (vpath2, &super2, 0);
if (crpath2 == NULL)
return -1;
@ -1238,7 +1238,7 @@ fish_symlink (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
struct vfs_s_super *super;
vfs_path_element_t *path_element = vfs_path_get_by_index (vpath1, -1);
crpath = vfs_s_get_path_mangle (vpath2, &super, 0);
crpath = vfs_s_get_path (vpath2, &super, 0);
if (crpath == NULL)
return -1;
rpath = strutils_shell_escape (crpath);
@ -1270,7 +1270,7 @@ fish_chmod (const vfs_path_t * vpath, int mode)
path_element = vfs_path_get_by_index (vpath, -1);
crpath = vfs_s_get_path_mangle (vpath, &super, 0);
crpath = vfs_s_get_path (vpath, &super, 0);
if (crpath == NULL)
return -1;
rpath = strutils_shell_escape (crpath);
@ -1314,7 +1314,7 @@ fish_chown (const vfs_path_t * vpath, uid_t owner, gid_t group)
path_element = vfs_path_get_by_index (vpath, -1);
crpath = vfs_s_get_path_mangle (vpath, &super, 0);
crpath = vfs_s_get_path (vpath, &super, 0);
if (crpath == NULL)
return -1;
rpath = strutils_shell_escape (crpath);
@ -1346,7 +1346,7 @@ fish_unlink (const vfs_path_t * vpath)
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
crpath = vfs_s_get_path_mangle (vpath, &super, 0);
crpath = vfs_s_get_path (vpath, &super, 0);
if (crpath == NULL)
return -1;
rpath = strutils_shell_escape (crpath);
@ -1373,7 +1373,7 @@ fish_exists (const vfs_path_t * vpath)
vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
crpath = vfs_s_get_path_mangle (vpath, &super, 0);
crpath = vfs_s_get_path (vpath, &super, 0);
if (crpath == NULL)
return -1;
rpath = strutils_shell_escape (crpath);
@ -1404,7 +1404,7 @@ fish_mkdir (const vfs_path_t * vpath, mode_t mode)
path_element = vfs_path_get_by_index (vpath, -1);
crpath = vfs_s_get_path_mangle (vpath, &super, 0);
crpath = vfs_s_get_path (vpath, &super, 0);
if (crpath == NULL)
return -1;
rpath = strutils_shell_escape (crpath);
@ -1442,7 +1442,7 @@ fish_rmdir (const vfs_path_t * vpath)
path_element = vfs_path_get_by_index (vpath, -1);
crpath = vfs_s_get_path_mangle (vpath, &super, 0);
crpath = vfs_s_get_path (vpath, &super, 0);
if (crpath == NULL)
return -1;
rpath = strutils_shell_escape (crpath);

View File

@ -1958,7 +1958,7 @@ ftpfs_send_command (const vfs_path_t * vpath, const char *cmd, int flags)
path_element = vfs_path_get_by_index (vpath, -1);
rpath = vfs_s_get_path_mangle (vpath, &super, 0);
rpath = vfs_s_get_path (vpath, &super, 0);
if (rpath == NULL)
return -1;