generate-squashfs: Add read-write flag

Add a read-write flag as default (since only the readonly
and preserved ones are defined) so that all partitions have
a flag field making the text line easier to parse.

Remove explicitly adding the scratch_dir to the path for
packaging the image so that when the image is extracted it
does not create the scratch_dir subdirectory.

Change-Id: I143abc33e2c7ce9c7bad8be005e323064a49dbe9
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/generate-squashfs b/generate-squashfs
index 6b14618..4a82b40 100755
--- a/generate-squashfs
+++ b/generate-squashfs
@@ -76,9 +76,10 @@
         miscflags=0x$(xxd -p -l  0x1 -seek ${offset} ${scratch_dir}/part)
         if ((miscflags & 0x80)); then
           flags+=",PRESERVED"
-        fi
-        if ((miscflags & 0x40)); then
+        elif ((miscflags & 0x40)); then
           flags+=",READONLY"
+        else
+          flags+=",READWRITE"
         fi
 
         # Need the partition ID, name, start location, end location, and flags
@@ -100,15 +101,15 @@
 
 echo "Creating SquashFS image..."
 cd "${scratch_dir}"
-mksquashfs ${tocfile} ${partitions[*]} ${scratch_dir}/pnor.xz.squashfs
+mksquashfs ${tocfile} ${partitions[*]} pnor.xz.squashfs
 
 echo "Creating MANIFEST for the image"
-manifest_location="${scratch_dir}/MANIFEST"
+manifest_location="MANIFEST"
 echo -e "purpose=host\nversion=$version\n\
 extended_version=$extended_version" >> $manifest_location
 
 echo "Generating tarball to contain the SquashFS image and its MANIFEST"
-tar -cvf $outfile $manifest_location ${scratch_dir}/pnor.xz.squashfs
+tar -cvf $outfile $manifest_location pnor.xz.squashfs
 
 echo "SquashFSTarball at ${outfile}"
 rm -r "${scratch_dir}"