Code Review
/
src
/
app-framework-main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Add discovery of API
[src/app-framework-main.git]
/
src
/
wgtpkg-workdir.c
diff --git
a/src/wgtpkg-workdir.c
b/src/wgtpkg-workdir.c
index
342df48
..
d0f1472
100644
(file)
--- a/
src/wgtpkg-workdir.c
+++ b/
src/wgtpkg-workdir.c
@@
-1,5
+1,5
@@
/*
/*
- Copyright
2015
IoT.bzh
+ Copyright
(C) 2015-2019
IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
author: José Bollo <jose.bollo@iot.bzh>
@@
-34,7
+34,7
@@
#include "wgtpkg-workdir.h"
#include "utils-dir.h"
#include "wgtpkg-workdir.h"
#include "utils-dir.h"
-static const
in
t dirmode = 0755;
+static const
mode_
t dirmode = 0755;
char workdir[PATH_MAX] = { 0, };
int workdirfd = -1;
char workdir[PATH_MAX] = { 0, };
int workdirfd = -1;
@@
-61,7
+61,7
@@
static void put_workdir(int fd, const char *name, size_t length)
workdir[1] = 0;
workdirfd = AT_FDCWD;
} else {
workdir[1] = 0;
workdirfd = AT_FDCWD;
} else {
-
+
assert(length < sizeof workdir);
memcpy(workdir, name, 1 + length);
workdirfd = fd;
assert(length < sizeof workdir);
memcpy(workdir, name, 1 + length);
workdirfd = fd;
@@
-81,6
+81,12
@@
int set_workdir(const char *name, int create)
return -1;
}
return -1;
}
+ /* check if . */
+ if (length == 1 && name[0] == '.') {
+ put_workdir(AT_FDCWD, name, length);
+ return 0;
+ }
+
/* opens the directory */
dirfd = openat(AT_FDCWD, name, O_PATH|O_DIRECTORY|O_RDONLY);
if (dirfd < 0) {
/* opens the directory */
dirfd = openat(AT_FDCWD, name, O_PATH|O_DIRECTORY|O_RDONLY);
if (dirfd < 0) {
@@
-116,7
+122,7
@@
int make_workdir(const char *root, const char *prefix, int reuse)
put_workdir(AT_FDCWD, ".", 1);
n = snprintf(workdir, sizeof workdir, "%s/%s", root, prefix);
put_workdir(AT_FDCWD, ".", 1);
n = snprintf(workdir, sizeof workdir, "%s/%s", root, prefix);
- if (n >= sizeof workdir) {
+ if (n >=
(int)
sizeof workdir) {
ERROR("workdir prefix too long");
errno = EINVAL;
return -1;
ERROR("workdir prefix too long");
errno = EINVAL;
return -1;
@@
-129,7
+135,7
@@
int make_workdir(const char *root, const char *prefix, int reuse)
ERROR("exhaustion of workdirs");
return -1;
}
ERROR("exhaustion of workdirs");
return -1;
}
- l = snprintf(workdir + n, r, "%d", i);
+ l = snprintf(workdir + n,
(unsigned)
r, "%d", i);
if (l >= r) {
ERROR("computed workdir too long");
errno = EINVAL;
if (l >= r) {
ERROR("computed workdir too long");
errno = EINVAL;
@@
-156,7
+162,8
@@
int make_workdir(const char *root, const char *prefix, int reuse)
int move_workdir(const char *dest, int parents, int force)
{
int move_workdir(const char *dest, int parents, int force)
{
- int rc, len;
+ int rc;
+ size_t len;
struct stat s;
char *copy;
const char *iter;
struct stat s;
char *copy;
const char *iter;
@@
-194,7
+201,7
@@
int move_workdir(const char *dest, int parents, int force)
} else {
/* check parent of dest */
iter = strrchr(dest, '/');
} else {
/* check parent of dest */
iter = strrchr(dest, '/');
- len = iter ?
iter - dest
: 0;
+ len = iter ?
(size_t)(iter - dest)
: 0;
if (len) {
/* is parent existing? */
copy = strndupa(dest, len);
if (len) {
/* is parent existing? */
copy = strndupa(dest, len);