chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
udevadm: add --version --help options to man page, hide them as commands
[elogind.git]
/
extras
/
volume_id
/
lib
/
util.c
diff --git
a/extras/volume_id/lib/util.c
b/extras/volume_id/lib/util.c
index 0a3bd39992c46b538401bdca295f474e1c31f953..e71d6208c5aadc325398318752943d882979fd21 100644
(file)
--- a/
extras/volume_id/lib/util.c
+++ b/
extras/volume_id/lib/util.c
@@
-26,6
+26,7
@@
#include <sys/stat.h>
#include "libvolume_id.h"
#include <sys/stat.h>
#include "libvolume_id.h"
+#include "libvolume_id-private.h"
#include "util.h"
/* count of characters used to encode one unicode char */
#include "util.h"
/* count of characters used to encode one unicode char */
@@
-268,7
+269,6
@@
void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, size_t len, en
count = 4;
break;
case UUID_64BIT_LE:
count = 4;
break;
case UUID_64BIT_LE:
- case UUID_64BIT_BE:
count = 8;
break;
case UUID_DCE:
count = 8;
break;
case UUID_DCE:
@@
-301,11
+301,6
@@
set:
buf[7], buf[6], buf[5], buf[4],
buf[3], buf[2], buf[1], buf[0]);
break;
buf[7], buf[6], buf[5], buf[4],
buf[3], buf[2], buf[1], buf[0]);
break;
- case UUID_64BIT_BE:
- sprintf(id->uuid,"%02X%02X%02X%02X%02X%02X%02X%02X",
- buf[0], buf[1], buf[2], buf[3],
- buf[4], buf[5], buf[6], buf[7]);
- break;
case UUID_DCE:
sprintf(id->uuid,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
case UUID_DCE:
sprintf(id->uuid,
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
@@
-353,33
+348,33
@@
uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
{
ssize_t buf_len;
{
ssize_t buf_len;
- info("get buffer off 0x%llx(%llu), len 0x%zx", (unsigned long long) off, (unsigned long long) off, len);
+ info("get buffer off 0x%llx(%llu), len 0x%zx
\n
", (unsigned long long) off, (unsigned long long) off, len);
/* check if requested area fits in superblock buffer */
if (off + len <= SB_BUFFER_SIZE) {
if (id->sbbuf == NULL) {
id->sbbuf = malloc(SB_BUFFER_SIZE);
if (id->sbbuf == NULL) {
/* check if requested area fits in superblock buffer */
if (off + len <= SB_BUFFER_SIZE) {
if (id->sbbuf == NULL) {
id->sbbuf = malloc(SB_BUFFER_SIZE);
if (id->sbbuf == NULL) {
- dbg("error malloc");
+ dbg("error malloc
\n
");
return NULL;
}
}
/* check if we need to read */
if ((off + len) > id->sbbuf_len) {
return NULL;
}
}
/* check if we need to read */
if ((off + len) > id->sbbuf_len) {
- info("read sbbuf len:0x%llx", (unsigned long long) (off + len));
+ info("read sbbuf len:0x%llx
\n
", (unsigned long long) (off + len));
if (lseek(id->fd, 0, SEEK_SET) < 0) {
if (lseek(id->fd, 0, SEEK_SET) < 0) {
- dbg("lseek failed (%s)", strerror(errno));
+ dbg("lseek failed (%s)
\n
", strerror(errno));
return NULL;
}
buf_len = read(id->fd, id->sbbuf, off + len);
if (buf_len < 0) {
return NULL;
}
buf_len = read(id->fd, id->sbbuf, off + len);
if (buf_len < 0) {
- dbg("read failed (%s)", strerror(errno));
+ dbg("read failed (%s)
\n
", strerror(errno));
return NULL;
}
return NULL;
}
- dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
+ dbg("got 0x%zx (%zi) bytes
\n
", buf_len, buf_len);
id->sbbuf_len = buf_len;
if ((size_t)buf_len < off + len) {
id->sbbuf_len = buf_len;
if ((size_t)buf_len < off + len) {
- dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
+ dbg("requested 0x%zx bytes, got only 0x%zx bytes
\n
", len, buf_len);
return NULL;
}
}
return NULL;
}
}
@@
-387,7
+382,7
@@
uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
return &(id->sbbuf[off]);
} else {
if (len > SEEK_BUFFER_SIZE) {
return &(id->sbbuf[off]);
} else {
if (len > SEEK_BUFFER_SIZE) {
- dbg("seek buffer too small %d", SEEK_BUFFER_SIZE);
+ dbg("seek buffer too small %d
\n
", SEEK_BUFFER_SIZE);
return NULL;
}
return NULL;
}
@@
-395,28
+390,28
@@
uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
if (id->seekbuf == NULL) {
id->seekbuf = malloc(SEEK_BUFFER_SIZE);
if (id->seekbuf == NULL) {
if (id->seekbuf == NULL) {
id->seekbuf = malloc(SEEK_BUFFER_SIZE);
if (id->seekbuf == NULL) {
- dbg("error malloc");
+ dbg("error malloc
\n
");
return NULL;
}
}
/* check if we need to read */
if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
return NULL;
}
}
/* check if we need to read */
if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
- info("read seekbuf off:0x%llx len:0x%zx", (unsigned long long) off, len);
+ info("read seekbuf off:0x%llx len:0x%zx
\n
", (unsigned long long) off, len);
if (lseek(id->fd, off, SEEK_SET) < 0) {
if (lseek(id->fd, off, SEEK_SET) < 0) {
- dbg("lseek failed (%s)", strerror(errno));
+ dbg("lseek failed (%s)
\n
", strerror(errno));
return NULL;
}
buf_len = read(id->fd, id->seekbuf, len);
if (buf_len < 0) {
return NULL;
}
buf_len = read(id->fd, id->seekbuf, len);
if (buf_len < 0) {
- dbg("read failed (%s)", strerror(errno));
+ dbg("read failed (%s)
\n
", strerror(errno));
return NULL;
}
return NULL;
}
- dbg("got 0x%zx (%zi) bytes", buf_len, buf_len);
+ dbg("got 0x%zx (%zi) bytes
\n
", buf_len, buf_len);
id->seekbuf_off = off;
id->seekbuf_len = buf_len;
if ((size_t)buf_len < len) {
id->seekbuf_off = off;
id->seekbuf_len = buf_len;
if ((size_t)buf_len < len) {
- dbg("requested 0x%zx bytes, got only 0x%zx bytes", len, buf_len);
+ dbg("requested 0x%zx bytes, got only 0x%zx bytes
\n
", len, buf_len);
return NULL;
}
}
return NULL;
}
}