• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/msdosfs-209.1.1/userfs_plugin/

Lines Matching +defs:child +defs:name

52     const char *name;               // malloc'ed; must be freed when stream is freed
116 // The maximum length of a FAT file name when converted to UTF-8
135 static int dir_lookup(userfs_stream_t parent, const uint8_t *child_name, size_t child_name_length, userfs_stream_t *child);
240 static int fsck_msdos(int fd, const char *name)
244 pid_t child, child_found;
261 result = posix_spawn(&child,
269 asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s: posix_spawn fsck_msdos: error=%d\n", name, result);
273 // Wait for child to finish
275 child_found = waitpid(child, &child_status, 0);
280 asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s: waitpid fsck_msdos: errno=%d\n", name, errno);
288 asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s: fsck_msdos: exited with status %d\n", name, result);
293 asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s: fsck_msdos: terminated by signal %d\n", name, WTERMSIG(child_status));
753 static userfs_stream_t volume_create_stream(userfs_volume_t v, const char *name, uint32_t cluster, uint64_t length)
759 stream->name = name ? strdup(name) : NULL;
813 userfs_stream_t child = NULL;
821 // Skip over previous separator to find start of name
827 // Find child name
830 // search current directory for child with the given name
831 err = dir_lookup(item, (const uint8_t *)path, child_name_length, &child);
837 item = child;
838 child = NULL;
994 static void direntry_get_short_name(const struct dosdirentry *entry, struct unistr255 *name)
1000 * Convert the base name portion to UTF-8
1002 name->length = 0;
1017 * If the base name was supposed to be lower case,
1029 name->chars[name->length++] = ch;
1033 * Get rid of trailing space padding in the base name.
1035 while (name->length && name->chars[name->length-1] == ' ')
1037 name->length--;
1043 name->chars[name->length++] = '.';
1061 name->chars[name->length++] = ch;
1068 for (i=0; i<sizeof(entry->deExtension) && name->chars[name->length-1] == ' '; ++i)
1070 name->length--;
1073 name->length--; /* Yes, so remove the dot, too. */
1079 static u_int8_t msdosfsNameChecksum(u_int8_t *name)
1084 for (s = 0, i = 0; i < SHORT_NAME_LEN; ++i, s += *name++)
1155 * The UTF-16 code points in a long name directory entry are scattered across
1171 * the "offset" parameter. For items with a long (Unicode) name, this is the
1172 * offset of the first long name entry; otherwise it is the offset of the short
1173 * name entry. The callback receives a pointer to the short name entry via the
1174 * "entry" parameter. The callback receives the item's name via the "name"
1175 * parameter. If the item has a long (Unicode) name, then "name" contains that
1176 * long name; otherwise, it contains the short (8.3-style) name.
1181 static errno_t dir_enumerate(userfs_stream_t dir, uint64_t dirOffset, int (^callback)(uint64_t offset, struct dosdirentry *entry, const struct unistr255 *name))
1185 __block int longNameChecksum; // -1 if not processing long name entries
1186 __block int longNameIndex; // Last long name ordinal, or 0
1187 __block struct unistr255 name;
1190 longNameChecksum = -1; // No long name entries seen so far
1209 longNameChecksum = -1; // Stop collecting long name entries
1217 longNameChecksum = -1; // Stop collecting long name entries
1221 /* If it's a long name entry, gather the characters */
1234 // Guess at the long name's length. If we see a NULL
1236 name.length = longNameIndex * WIN_CHARS;
1241 longNameChecksum = -1; // Not a valid long name.
1245 // Compute offset of this long entry within the whole Unicode name
1248 // Copy the UTF-16 code points from the long name
1254 /* Did we find the NUL terminator for the name? */
1257 /* It must be in the last long name entry */
1260 name.length = unicodeIndex + i;
1264 // Can't have NUL char in middle of long name!
1279 name.chars[unicodeIndex + i] = ch;
1286 /* Skip over volume name entries */
1289 longNameChecksum = -1; // Stop collecting long name entries
1294 * If we get here, we must have found a short name entry.
1299 /* Long name didn't match short name, so ignore long name */
1301 direntry_get_short_name(entry, &name);
1304 longNameChecksum = -1; // Don't associate long name with future children
1305 return callback(initialOffset, entry, &name);
1330 // In the directory "parent", search for a child matching the given name. If found, create and return that child.
1334 // child_name The UTF-8 name of the child.
1338 // child The found child (if any) is returned here. On error, this
1341 // Result: 0 if the child was found
1342 // ENOENT if there was no child with the given name
1345 static errno_t dir_lookup(userfs_stream_t parent, const uint8_t *child_name, size_t child_name_length, userfs_stream_t *child)
1347 *child = NULL;
1356 /* Convert the search name to UTF-16 */
1361 /* Iterate through the directory looking for a short name match */
1362 err = dir_enumerate(parent, 0, ^int(uint64_t offset, struct dosdirentry *entry, const struct unistr255 *name) {
1364 if (searchName.length != name->length)
1372 ch2 = name->chars[i];
1381 unistr255_to_utf8(name, utf8);
1386 *child = volume_create_stream(volume, utf8, cluster, getuint32(entry->deFileSize));
1387 (*child)->dirEntryOffset = offset;
1388 (*child)->create_date = timestamp_to_nanoseconds(getuint16(entry->deCDate), getuint16(entry->deCTime), entry->deCHundredth);
1389 (*child)->mod_date = timestamp_to_nanoseconds(getuint16(entry->deMDate), getuint16(entry->deMTime), 0);
1392 (*child)->directory = true;
1399 msdosfs_stream_close(*child);
1400 *child = NULL;
1403 (*child)->length = (uint64_t)numClusters * volume->bytesPerCluster;
1406 (*child)->locked = true;
2108 xpc_dictionary_set_string(info, USERFSD_PARM_NAME, item->name);
2166 err = dir_enumerate(dir, offset, ^int(uint64_t offset, struct dosdirentry *entry, const struct unistr255 *name) {
2190 xpc_dictionary_set_unistr255(info, USERFSD_PARM_NAME, name);
2224 userfs_stream_t child = NULL;
2226 errno_t error = volume_lookup(volume, path, &child, &parent);
2229 if (child->directory)
2234 if (child->locked)
2245 // Delete the directory entries for the child
2246 error = dir_delete_entries(parent, child->dirEntryOffset);
2250 // Delete the clusters allocated to the child
2251 if (child->startingCluster)
2254 error = chain_free(volume, child->startingCluster, &numFreed);
2262 msdosfs_stream_close(child);
2294 asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s: %s: Attempt to read offset beyond EOF (offset=%llu, EOF=%llu)\n", device_name(stream->volume->device), stream->name, offset, stream->length);
2299 asl_log(NULL, NULL, ASL_LEVEL_ERR, "%s: %s: Attempt to read beyond EOF (offset=%llu, length=%lu, EOF=%llu)\n", device_name(stream->volume->device), stream->name, offset, (unsigned long)length, stream->length);
2331 if (stream->name)
2332 free((void*)stream->name);
2339 return stream->name;