commit b9f30fdb2f041505d0ec9af5941de80d908e0f58
Author: Yiannis Pericleous <[EMAIL PROTECTED]>
Date: Fri Mar 30 18:23:56 2007 -0400
store uuids in memory and keep them consinstent throughout remounts
diff --git a/fs/unionfs/odf.c b/fs/unionfs/odf.c
index 083d0d0..de55971 100644
--- a/fs/unionfs/odf.c
+++ b/fs/unionfs/odf.c
@@ -1891,6 +1891,59 @@ void odf_unset_newbit(struct odf_sb_info *osi)
}
/*
+ * Generates uuids for branches and makes sure branches belonging to the same
+ * filesystem get the same uuid.
+ */
+int odf_update_uuids(struct odf_sb_info *odf, struct path *old_paths, int
old_branches,
+ struct path *new_paths, int new_branches)
+{
+ struct vfsmount *m;
+ char *old_uuids = odf->branch_uuids;
+ char *new_uuids;
+ int err = 0, bindex, i;
+
+ new_uuids = kmalloc(new_branches * UUID_LEN, GFP_KERNEL);
+ if (!new_uuids) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ for (bindex = 0; bindex < new_branches; bindex++) {
+
+ m = new_paths[bindex].mnt;
+
+ /* check if this fs was in the old uuids */
+ for (i = 0; i < old_branches; i++) {
+ if (m == old_paths[i].mnt)
+ break;
+ }
+
+ /* if yes, then give it the old uuid */
+ if (i != old_branches) {
+ memcpy(new_uuids + bindex * UUID_LEN, old_uuids + i *
UUID_LEN, UUID_LEN);
+ continue;
+ }
+
+ /* now check the processed new branches */
+ for (i = 0; i < bindex; i++) {
+ if (m == new_paths[i].mnt)
+ break;
+ }
+
+ if (i != bindex)
+ memcpy(new_uuids + bindex * UUID_LEN, new_uuids + i *
UUID_LEN, UUID_LEN);
+
+ else /* if this is a new fs in the union give it a new uuid
*/
+ generate_random_uuid(new_uuids + bindex * UUID_LEN);
+ }
+
+ kfree(odf->branch_uuids);
+ odf->branch_uuids = new_uuids;
+
+out:
+ return err;
+}
+/*
* Writes the superblock data for new odf's, generates branch UUID's
* Superblock contains:
* odf version number, numbers of branches
@@ -1906,8 +1959,6 @@ int odf_write_sb_data(struct odf_sb_info* osi, struct
unionfs_data *data, struct
int len, bindex;
int err = 0;
__le32 le32;
- unsigned char *uuid = NULL;
- u32 *buuid = NULL;
char *branch_entry = kmalloc(ODF_BRANCH_PATH, GFP_KERNEL);
char *branch_path = kmalloc(ODF_BRANCH_PATH, GFP_KERNEL);
mm_segment_t oldfs;
@@ -1972,14 +2023,6 @@ int odf_write_sb_data(struct odf_sb_info* osi, struct
unionfs_data *data, struct
goto out_close;
}
- buuid = kmalloc(branches * sizeof(u32), GFP_KERNEL);
- uuid = kmalloc(branches * UUID_LEN, GFP_KERNEL);
- if (!buuid || !uuid) {
- err = -ENOMEM;
- goto out_close;
- }
- count = 0;
-
/* now info about each branch */
for (bindex = 0; bindex < branches; bindex++) {
@@ -2036,8 +2079,6 @@ out_close:
set_fs(oldfs);
filp_close(file,NULL);
out:
- kfree(uuid);
- kfree(buuid);
kfree(branch_path);
kfree(branch_entry);
return err;
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs