Whamcloud - gitweb
git://git.whamcloud.com
/
tools
/
e2fsprogs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
debugfs: dump "fid" and "lma" xattrs on inode stat
[tools/e2fsprogs.git]
/
misc
/
uuidd.c
diff --git
a/misc/uuidd.c
b/misc/uuidd.c
index
e2d3656
..
4db3fa9
100644
(file)
--- a/
misc/uuidd.c
+++ b/
misc/uuidd.c
@@
-11,6
+11,7
@@
#define _GNU_SOURCE /* for setres[ug]id() */
#define _GNU_SOURCE /* for setres[ug]id() */
+#include "config.h"
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
@@
-34,7
+35,8
@@
extern int optind;
#endif
#include "uuid/uuid.h"
#include "uuid/uuidd.h"
#endif
#include "uuid/uuid.h"
#include "uuid/uuidd.h"
-#include "nls-enable.h"
+#include "support/nls-enable.h"
+#include "ext2fs/ext2fs.h"
#ifdef __GNUC__
#define CODE_ATTR(x) __attribute__(x)
#ifdef __GNUC__
#define CODE_ATTR(x) __attribute__(x)
@@
-85,19
+87,23
@@
static void create_daemon(void)
die("setreuid");
}
die("setreuid");
}
-static
in
t read_all(int fd, char *buf, size_t count)
+static
ssize_
t read_all(int fd, char *buf, size_t count)
{
ssize_t ret;
{
ssize_t ret;
- int c = 0;
+ ssize_t c = 0;
+ int tries = 0;
memset(buf, 0, count);
while (count > 0) {
ret = read(fd, buf, count);
memset(buf, 0, count);
while (count > 0) {
ret = read(fd, buf, count);
- if (ret < 0) {
- if ((errno == EAGAIN) || (errno == EINTR))
+ if (ret <= 0) {
+ if ((errno == EAGAIN || errno == EINTR || ret == 0) &&
+ (tries++ < 5))
continue;
continue;
- return -1;
+ return
c ? c :
-1;
}
}
+ if (ret > 0)
+ tries = 0;
count -= ret;
buf += ret;
c += ret;
count -= ret;
buf += ret;
c += ret;
@@
-231,7
+237,7
@@
static void server_loop(const char *socket_path, const char *pidfile_path,
uuid_t uu;
mode_t save_umask;
char reply_buf[1024], *cp;
uuid_t uu;
mode_t save_umask;
char reply_buf[1024], *cp;
- char op, str[
37
];
+ char op, str[
UUID_STR_SIZE
];
int i, s, ns, len, num;
int fd_pidfile, ret;
int i, s, ns, len, num;
int fd_pidfile, ret;
@@
-276,6
+282,18
@@
static void server_loop(const char *socket_path, const char *pidfile_path,
}
/*
}
/*
+ * Make sure the socket isn't using fd numbers 0-2 to avoid it
+ * getting closed by create_daemon()
+ */
+ while (!debug && s <= 2) {
+ s = dup(s);
+ if (s < 0) {
+ perror("dup");
+ exit(1);
+ }
+ }
+
+ /*
* Create the address we will be binding to.
*/
my_addr.sun_family = AF_UNIX;
* Create the address we will be binding to.
*/
my_addr.sun_family = AF_UNIX;
@@
-379,8
+397,11
@@
static void server_loop(const char *socket_path, const char *pidfile_path,
uuid__generate_time(uu, &num);
if (debug) {
uuid_unparse(uu, str);
uuid__generate_time(uu, &num);
if (debug) {
uuid_unparse(uu, str);
- printf(_("Generated time UUID %s and %d "
- "following\n"), str, num);
+ printf(P_("Generated time UUID %s and "
+ "subsequent UUID\n",
+ "Generated time UUID %s and %d "
+ "subsequent UUIDs\n", num),
+ str, num);
}
memcpy(reply_buf, uu, sizeof(uu));
reply_len = sizeof(uu);
}
memcpy(reply_buf, uu, sizeof(uu));
reply_len = sizeof(uu);
@@
-456,6
+477,7
@@
int main(int argc, char **argv)
fprintf(stderr, _("Bad number: %s\n"), optarg);
exit(1);
}
fprintf(stderr, _("Bad number: %s\n"), optarg);
exit(1);
}
+ break;
case 'p':
pidfile_path = optarg;
drop_privs = 1;
case 'p':
pidfile_path = optarg;
drop_privs = 1;
@@
-519,9
+541,11
@@
int main(int argc, char **argv)
uuid_unparse((unsigned char *) buf, str);
uuid_unparse((unsigned char *) buf, str);
- printf(_("%s and subsequent %d UUID's\n"), str, num);
+ printf(P_("%s and subsequent UUID\n",
+ "%s and subsequent %d UUIDs\n", num),
+ str, num);
} else {
} else {
- printf(_("List of UUID's:\n"));
+ printf(
"%s",
_("List of UUID's:\n"));
cp = buf + 4;
if (ret != (int) (sizeof(num) + num*sizeof(uu)))
goto unexpected_size;
cp = buf + 4;
if (ret != (int) (sizeof(num) + num*sizeof(uu)))
goto unexpected_size;