Commits

Stephen Smalley  committed 6ac33cf Merge

Merge tag 'android-4.2.2_r1' into seandroid-4.2.2

Android 4.2.2 release 1

  • Participants
  • Parent commits 30c8b6b, 917e120

Comments (0)

Files changed (3)

File ext4_utils/contents.c

 		len += dentry_len;
 	}
 
-	/* include size of the dentry used to pad until the end of the block */
-	if (len % info.block_size + 8 > info.block_size)
-		len += info.block_size - (len % info.block_size);
-	len += 8;
-
 	return len;
 }
 
 		}
 	}
 
-	dentry = (struct ext4_dir_entry_2 *)(data + offset);
-	dentry->inode = 0;
-	dentry->rec_len = len - offset;
-	dentry->name_len = 0;
-	dentry->file_type = EXT4_FT_UNKNOWN;
+	/* pad the last dentry out to the end of the block */
+	dentry->rec_len += len - offset;
 
 	return inode_num;
 }

File ext4_utils/make_ext4fs.c

 {
 	int entries = 0;
 	struct dentry *dentries;
-	struct dirent **namelist;
+	struct dirent **namelist = NULL;
 	struct stat stat;
 	int ret;
 	int i;
 	u32 inode;
 	u32 entry_inode;
 	u32 dirs = 0;
+	bool needs_lost_and_found = false;
 
-	entries = scandir(full_path, &namelist, filter_dot, (void*)alphasort);
-	if (entries < 0) {
-		error_errno("scandir");
-		return EXT4_ALLOCATE_FAILED;
+	if (full_path) {
+		entries = scandir(full_path, &namelist, filter_dot, (void*)alphasort);
+		if (entries < 0) {
+			error_errno("scandir");
+			return EXT4_ALLOCATE_FAILED;
+		}
+	}
+
+	if (dir_inode == 0) {
+		/* root directory, check if lost+found already exists */
+		for (i = 0; i < entries; i++)
+			if (strcmp(namelist[i]->d_name, "lost+found") == 0)
+				break;
+		if (i == entries)
+			needs_lost_and_found = true;
 	}
 
 	dentries = calloc(entries, sizeof(struct dentry));
 	}
 	free(namelist);
 
+	if (needs_lost_and_found) {
+		/* insert a lost+found directory at the beginning of the dentries */
+		struct dentry *tmp = calloc(entries + 1, sizeof(struct dentry));
+		memset(tmp, 0, sizeof(struct dentry));
+		memcpy(tmp + 1, dentries, entries * sizeof(struct dentry));
+		dentries = tmp;
+
+		dentries[0].filename = strdup("lost+found");
+		asprintf(&dentries[0].path, "%s/lost+found", dir_path);
+		dentries[0].full_path = NULL;
+		dentries[0].size = 0;
+		dentries[0].mode = S_IRWXU;
+		dentries[0].file_type = EXT4_FT_DIR;
+		dentries[0].uid = 0;
+		dentries[0].gid = 0;
+#ifdef HAVE_SELINUX
+		if (sehnd) {
+			char *sepath = NULL;
+			asprintf(&sepath, "/%s", dentries[0].path);
+			if (selabel_lookup(sehnd, &dentries[0].secon, sepath, dentries[0].mode) < 0)
+				error("cannot lookup security context for %s", dentries[0].path);
+			free(sepath);
+		}
+#endif
+		entries++;
+		dirs++;
+	}
+
 	inode = make_directory(dir_inode, entries, dentries, dirs);
 
 	for (i = 0; i < entries; i++) {

File tests/wifi/stress/wifiLoadScanAssoc.c

 
         // Stop Supplicant
         randBind(&availCPU, &cpu);
-        if ((rv = wifi_stop_supplicant()) != 0) {
+        if ((rv = wifi_stop_supplicant(false)) != 0) {
             testPrintE("CPU: %i wifi_stop_supplicant() failed, rv: %i\n",
                 cpu, rv);
             exit(23);
         // Stop wpa_supplicant
         // Might already be stopped, in which case request should
         // return immediately with success.
-        if ((rv = wifi_stop_supplicant()) != 0) {
+        if ((rv = wifi_stop_supplicant(false)) != 0) {
             testPrintE("init stop supplicant failed, rv: %i", rv);
             exit(42);
         }