Lines Matching defs:filename
83 static BlockDriverState *bdrv_open_inherit(const char *filename,
117 static int is_windows_drive_prefix(const char *filename)
119 return (((filename[0] >= 'a' && filename[0] <= 'z') ||
120 (filename[0] >= 'A' && filename[0] <= 'Z')) &&
121 filename[1] == ':');
124 int is_windows_drive(const char *filename)
126 if (is_windows_drive_prefix(filename) &&
127 filename[2] == '\0')
129 if (strstart(filename, "\\\\.\\", NULL) ||
130 strstart(filename, "//./", NULL))
189 /* if filename is absolute, just return its duplicate. Otherwise, build a
192 char *path_combine(const char *base_path, const char *filename)
199 if (path_is_absolute(filename)) {
200 return g_strdup(filename);
231 result = g_malloc(len + strlen(filename) + 1);
233 strcpy(result + len, filename);
240 * protocol prefixes (especially "file:") from a filename and for putting the
241 * stripped filename into the options QDict if there is such a prefix.
243 void bdrv_parse_filename_strip_prefix(const char *filename, const char *prefix,
246 if (strstart(filename, prefix, &filename)) {
248 * prefix being (wrongly) detected (if the filename contains a colon) */
249 if (path_has_protocol(filename)) {
254 assert(!path_is_absolute(filename));
259 g_string_append(fat_filename, filename);
263 qdict_put(options, "filename",
267 * filename as-is */
268 qdict_put_str(options, "filename", filename);
352 * absolute filename cannot be generated.
372 * If @filename is empty or NULL, this function returns NULL without
378 const char *filename, Error **errp)
382 if (!filename || filename[0] == '\0') {
384 } else if (path_has_protocol(filename) || path_is_absolute(filename)) {
385 return g_strdup(filename);
393 full_name = g_strconcat(dir, filename, NULL);
529 char *filename;
535 int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename,
548 ret = drv->bdrv_co_create_opts(drv, filename, opts, errp);
633 const char *filename,
667 blk = blk_co_new_open(filename, NULL, options,
695 int coroutine_fn bdrv_co_create_file(const char *filename, QemuOpts *opts,
705 drv = bdrv_find_protocol(filename, true, errp);
737 ret = bdrv_co_create(drv, filename, protocol_opts, errp);
754 error_setg(errp, "Block node '%s' is not opened", bs->filename);
854 g_autofree char *filename = NULL;
870 filename = g_strdup_printf("%s/vl.XXXXXX", tmpdir);
871 fd = g_mkstemp(filename);
874 filename);
879 return g_steal_pointer(&filename);
886 static BlockDriver *find_hdev_driver(const char *filename)
894 score = d->bdrv_probe_device(filename);
919 BlockDriver *bdrv_find_protocol(const char *filename,
938 drv1 = find_hdev_driver(filename);
943 if (!path_has_protocol(filename) || !allow_protocol_prefix) {
947 p = strchr(filename, ':');
949 len = p - filename;
952 memcpy(protocol, filename, len);
987 * @filename is its filename.
994 const char *filename)
1002 score = d->bdrv_probe(buf, buf_size, filename);
1013 static int find_image_format(BlockBackend *file, const char *filename,
1036 drv = bdrv_probe_all(buf, sizeof(buf), filename);
1313 const char *filename,
1346 ret = bdrv_change_backing_file(parent, filename, format_name, false);
1500 const char *filename,
1505 return bdrv_backing_update_filename(c, base, filename,
1658 assert(!drv->bdrv_needs_filename || bs->filename[0]);
1668 } else if (bs->filename[0]) {
1669 error_setg_errno(errp, -ret, "Could not open '%s'", bs->filename);
1858 const char *filename;
1901 filename = blk_bs(file)->filename;
1910 filename = qdict_get_try_str(options, "filename");
1913 if (drv->bdrv_needs_filename && (!filename || !filename[0])) {
1920 trace_bdrv_open_common(bs, filename ?: "", bs->open_flags,
1973 if (filename != NULL) {
1974 pstrcpy(bs->filename, sizeof(bs->filename), filename);
1976 bs->filename[0] = '\0';
1978 pstrcpy(bs->exact_filename, sizeof(bs->exact_filename), bs->filename);
1998 static QDict *parse_json_filename(const char *filename, Error **errp)
2006 ret = strstart(filename, "json:", &filename);
2009 options_obj = qobject_from_json(filename, errp);
2045 /* Options given in the filename have lower priority than options
2054 * filename/flags pair to option QDict entries.
2058 static int bdrv_fill_options(QDict **options, const char *filename,
2099 if (protocol && filename) {
2100 if (!qdict_haskey(*options, "filename")) {
2101 qdict_put_str(*options, "filename", filename);
2104 error_setg(errp, "Can't specify 'file' and 'filename' options at "
2112 filename = qdict_get_try_str(*options, "filename");
2115 if (filename) {
2116 drv = bdrv_find_protocol(filename, parse_filename, errp);
2131 /* Driver-specific filename parsing */
2133 drv->bdrv_parse_filename(filename, *options, &local_err);
2140 qdict_del(*options, "filename");
3627 if (reference || qdict_haskey(options, "file.filename")) {
3677 backing_hd->filename);
3698 bdrv_open_child_bs(const char *filename, QDict *options, const char *bdref_key,
3722 if (!filename && !reference && !qdict_size(image_options)) {
3731 bs = bdrv_open_inherit(filename, reference, image_options, 0,
3743 static BdrvChild *bdrv_open_child_common(const char *filename,
3756 bs = bdrv_open_child_bs(filename, options, bdref_key, parent, child_class,
3774 * If allow_none is true, no image will be opened if filename is false and no
3786 BdrvChild *bdrv_open_child(const char *filename,
3793 return bdrv_open_child_common(filename, options, bdref_key, parent,
3801 * enables filename parsing for protocol names (including json:).
3805 int bdrv_open_file_child(const char *filename,
3816 if (!bdrv_open_child_common(filename, options, bdref_key, parent,
3885 instead of opening 'filename' directly */
3914 qdict_put_str(snapshot_options, "file.filename", tmp_filename);
3946 * should be opened. If specified, neither options nor a filename may be given,
3950 bdrv_open_inherit(const char *filename, const char *reference, QDict *options,
3978 if (filename || options_non_empty) {
3980 "additional options or a new filename");
4002 parse_json_protocol(options, &filename, &local_err);
4030 ret = bdrv_fill_options(&options, filename, &flags, parse_filename,
4098 file_bs = bdrv_open_child_bs(filename, options, "file", bs,
4124 ret = find_image_format(file, filename, &drv, &local_err);
4243 BlockDriverState *bdrv_open(const char *filename, const char *reference,
4248 return bdrv_open_inherit(filename, reference, options, flags, NULL,
4920 reopen_state->bs->filename);
4976 * used for the initial open, but not reopen (e.g. filename) */
5889 backing_file_str = base->filename;
6546 char *filename, int filename_size)
6549 pstrcpy(filename, filename_size, bs->backing_file);
6699 * relative, it must be relative to the chain. So, passing in bs->filename
6741 * directly against the backing node's filename.
6754 if (strcmp(backing_file, bs_below->filename) == 0) {
6760 * If either of the filename paths is actually a protocol, then
6769 /* Also check against the full backing filename for the image */
6781 /* If not an absolute filename path, make it relative to the current
6782 * image's filename path */
6792 /* We need to make sure the backing filename we are comparing against
6793 * is relative to the current image filename (or absolute) */
7229 void bdrv_img_create(const char *filename, const char *fmt,
7251 proto_drv = bdrv_find_protocol(filename, true, errp);
7307 if (!strcmp(filename, backing_file)) {
7309 "same filename as the backing file");
7330 bdrv_get_full_backing_filename_from_filename(filename, backing_file,
7394 printf("Formatting '%s', fmt=%s ", filename, fmt);
7400 ret = bdrv_create(drv, filename, opts, &local_err);
7839 "driver", "filename", NULL
7860 * thus copied to the target QDict) with the exception of "filename"
7863 * a plain filename.
7899 /* While "driver" and "filename" need to be included in a JSON filename,
7900 * their existence does not prohibit generation of a plain filename. */
7902 strcmp(*option_name, "driver") && strcmp(*option_name, "filename"))
7925 bs->backing->bs->filename);
7934 * - exact_filename: A filename which may be used for opening a block device
7939 * (without a filename), result in a BDS (mostly)
7941 * - filename: If exact_filename is set, it is copied here. Otherwise,
7974 pstrcpy(bs->filename, sizeof(bs->filename), child->bs->filename);
8035 * filename which the filter driver must construct in its
8042 * We can use the underlying file's filename if:
8043 * - it has a filename,
8062 pstrcpy(bs->filename, sizeof(bs->filename), bs->exact_filename);
8065 if (snprintf(bs->filename, sizeof(bs->filename), "json:%s",
8066 json->str) >= sizeof(bs->filename)) {
8068 strcpy(bs->filename + sizeof(bs->filename) - 4, "...");
8191 c->bs->filename);
8274 * child that has the same filename as @bs.)