block.c (33886ebeec0c0ff6253a49253fae0db44c9ed0f3) | block.c (ada4240103470371533967334cda9965854fcbda) |
---|---|
1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 3730 unchanged lines hidden (view full) --- 3739 return ret; 3740} 3741 3742const char *bdrv_get_format_name(BlockDriverState *bs) 3743{ 3744 return bs->drv ? bs->drv->format_name : NULL; 3745} 3746 | 1/* 2 * QEMU System Emulator block driver 3 * 4 * Copyright (c) 2003 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 3730 unchanged lines hidden (view full) --- 3739 return ret; 3740} 3741 3742const char *bdrv_get_format_name(BlockDriverState *bs) 3743{ 3744 return bs->drv ? bs->drv->format_name : NULL; 3745} 3746 |
3747static int qsort_strcmp(const void *a, const void *b) 3748{ 3749 return strcmp(a, b); 3750} 3751 |
|
3747void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 3748 void *opaque) 3749{ 3750 BlockDriver *drv; 3751 int count = 0; | 3752void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 3753 void *opaque) 3754{ 3755 BlockDriver *drv; 3756 int count = 0; |
3757 int i; |
|
3752 const char **formats = NULL; 3753 3754 QLIST_FOREACH(drv, &bdrv_drivers, list) { 3755 if (drv->format_name) { 3756 bool found = false; 3757 int i = count; 3758 while (formats && i && !found) { 3759 found = !strcmp(formats[--i], drv->format_name); 3760 } 3761 3762 if (!found) { 3763 formats = g_renew(const char *, formats, count + 1); 3764 formats[count++] = drv->format_name; | 3758 const char **formats = NULL; 3759 3760 QLIST_FOREACH(drv, &bdrv_drivers, list) { 3761 if (drv->format_name) { 3762 bool found = false; 3763 int i = count; 3764 while (formats && i && !found) { 3765 found = !strcmp(formats[--i], drv->format_name); 3766 } 3767 3768 if (!found) { 3769 formats = g_renew(const char *, formats, count + 1); 3770 formats[count++] = drv->format_name; |
3765 it(opaque, drv->format_name); | |
3766 } 3767 } 3768 } | 3771 } 3772 } 3773 } |
3774 3775 qsort(formats, count, sizeof(formats[0]), qsort_strcmp); 3776 3777 for (i = 0; i < count; i++) { 3778 it(opaque, formats[i]); 3779 } 3780 |
|
3769 g_free(formats); 3770} 3771 3772/* This function is to find block backend bs */ 3773BlockDriverState *bdrv_find(const char *name) 3774{ 3775 BlockDriverState *bs; 3776 --- 2255 unchanged lines hidden --- | 3781 g_free(formats); 3782} 3783 3784/* This function is to find block backend bs */ 3785BlockDriverState *bdrv_find(const char *name) 3786{ 3787 BlockDriverState *bs; 3788 --- 2255 unchanged lines hidden --- |