#include <CoreFoundation/CoreFoundation.h>
#endif
+#ifdef __sun__
+#include <sys/dkio.h>
+#endif
+
static BlockDriverState *bdrv_first;
static BlockDriver *first_drv;
}
#ifdef _WIN32
-static void get_tmp_filename(char *filename, int size)
+void get_tmp_filename(char *filename, int size)
{
+ char* p = strrchr(filename, '/');
+
+ if (p == NULL)
+ return;
+
/* XXX: find a better function */
- tmpnam(filename);
+ tmpnam(p);
+ *p = '/';
}
#else
-static void get_tmp_filename(char *filename, int size)
+void get_tmp_filename(char *filename, int size)
{
int fd;
/* XXX: race condition possible */
i += n;
}
}
+
+ if (bs->drv->bdrv_make_empty)
+ return bs->drv->bdrv_make_empty(bs);
+
return 0;
}
}
}
-
/**************************************************************/
/* RAW block driver */
#ifdef _BSD
struct stat sb;
#endif
+#ifdef __sun__
+ struct dk_minfo minfo;
+ int rv;
+#endif
fd = open(filename, O_RDWR | O_BINARY | O_LARGEFILE);
if (fd < 0) {
#endif
} else
#endif
+#ifdef __sun__
+ /*
+ * use the DKIOCGMEDIAINFO ioctl to read the size.
+ */
+ rv = ioctl ( fd, DKIOCGMEDIAINFO, &minfo );
+ if ( rv != -1 ) {
+ size = minfo.dki_lbsize * minfo.dki_capacity;
+ } else /* there are reports that lseek on some devices
+ fails, but irc discussion said that contingency
+ on contingency was overkill */
+#endif
{
size = lseek(fd, 0, SEEK_END);
}