Allow building userdata partition in Soong

The soong vs make generated userdata images are still not bit identical,
but this change resolves execution time failure from build_image when
building userdata.img.

Implementation details:
- Introduce partition_size property to filesystem module
- Specify the correct mount point for userdata partition

Test: m out/soong/.intermediates/build/soong/fsgen/aosp_cf_x86_64_phone_generated_userdata_image/android_common/userdata.img
Bug: 388920173
Change-Id: I2c0945ce70d74c632ba241c8a93c60763cfe87e7
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 993c46e..a315160 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -218,6 +218,10 @@
 
 	// Name of the output. Default is $(module_name).img
 	Stem *string
+
+	// The size of the partition on the device. It will be a build error if this built partition
+	// image exceeds this size.
+	Partition_size *int64
 }
 
 type AndroidFilesystemDeps struct {
@@ -672,6 +676,10 @@
 		copyImageFileToProductOut(ctx, builder, f.partitionName(), output)
 	}
 
+	if f.properties.Partition_size != nil {
+		assertMaxImageSize(builder, output, *f.properties.Partition_size, false)
+	}
+
 	// rootDir is not deleted. Might be useful for quick inspection.
 	builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
 
@@ -809,6 +817,10 @@
 	}
 	f.checkFsTypePropertyError(ctx, fst, fsTypeStr(fst))
 
+	if f.properties.Partition_size != nil {
+		addStr("partition_size", strconv.FormatInt(*f.properties.Partition_size, 10))
+	}
+
 	propFilePreProcessing := android.PathForModuleOut(ctx, "prop_pre_processing")
 	android.WriteFileRuleVerbatim(ctx, propFilePreProcessing, propFileString.String())
 	propFile := android.PathForModuleOut(ctx, "prop")