Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
0c4826e3
Unverified
Commit
0c4826e3
authored
Dec 10, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
btrfs: fix get_btrfs_subvol_path()
Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
3893aee8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
15 deletions
+33
-15
btrfs.c
src/lxc/storage/btrfs.c
+32
-14
btrfs.h
src/lxc/storage/btrfs.h
+1
-1
No files found.
src/lxc/storage/btrfs.c
View file @
0c4826e3
...
...
@@ -41,6 +41,10 @@
#include "storage.h"
#include "utils.h"
#ifndef HAVE_STRLCAT
#include "include/strlcat.h"
#endif
#ifndef HAVE_STRLCPY
#include "include/strlcpy.h"
#endif
...
...
@@ -58,11 +62,11 @@ extern char *dir_new_path(char *src, const char *oldname, const char *name,
* simply return a.
*/
char
*
get_btrfs_subvol_path
(
int
fd
,
u64
dir_id
,
u64
objid
,
char
*
name
,
int
name_len
)
u16
name_len
)
{
struct
btrfs_ioctl_ino_lookup_args
args
;
int
ret
,
e
;
size_t
len
;
int
ret
;
size_t
len
,
retlen
;
char
*
retpath
;
memset
(
&
args
,
0
,
sizeof
(
args
));
...
...
@@ -70,17 +74,16 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
args
.
objectid
=
objid
;
ret
=
ioctl
(
fd
,
BTRFS_IOC_INO_LOOKUP
,
&
args
);
e
=
errno
;
if
(
ret
)
{
ERROR
(
"Failed to lookup path for %llu %llu %s - %s
\n
"
,
(
unsigned
long
long
)
dir_id
,
(
unsigned
long
long
)
objid
,
name
,
strerror
(
e
)
);
SYSERROR
(
"Failed to lookup path for %llu %llu %s
"
,
(
unsigned
long
long
)
dir_id
,
(
unsigned
long
long
)
objid
,
name
);
return
NULL
;
}
else
INFO
(
"Got path for %llu %llu - %s
\n
"
,
(
unsigned
long
long
)
objid
,
(
unsigned
long
long
)
dir_id
,
name
);
INFO
(
"Got path for %llu %llu - %s"
,
(
unsigned
long
long
)
objid
,
(
unsigned
long
long
)
dir_id
,
name
);
if
(
args
.
name
[
0
])
{
/*
...
...
@@ -91,18 +94,33 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
retpath
=
malloc
(
len
);
if
(
!
retpath
)
return
NULL
;
(
void
)
strlcpy
(
retpath
,
args
.
name
,
len
);
strncat
(
retpath
,
"/"
,
1
);
strncat
(
retpath
,
name
,
name_len
);
(
void
)
strlcat
(
retpath
,
"/"
,
len
);
retlen
=
strlcat
(
retpath
,
name
,
len
);
if
(
retlen
>=
len
)
{
ERROR
(
"Failed to append name - %s"
,
name
);
free
(
retpath
);
return
NULL
;
}
}
else
{
/* we're at the root of ref_tree */
len
=
name_len
+
1
;
retpath
=
malloc
(
len
);
if
(
!
retpath
)
return
NULL
;
*
retpath
=
'\0'
;
strncat
(
retpath
,
name
,
name_len
);
retlen
=
strlcat
(
retpath
,
name
,
len
);
if
(
retlen
>=
len
)
{
ERROR
(
"Failed to append name - %s"
,
name
);
free
(
retpath
);
return
NULL
;
}
}
return
retpath
;
}
...
...
src/lxc/storage/btrfs.h
View file @
0c4826e3
...
...
@@ -396,7 +396,7 @@ extern int btrfs_mount(struct lxc_storage *bdev);
extern
int
btrfs_umount
(
struct
lxc_storage
*
bdev
);
extern
char
*
get_btrfs_subvol_path
(
int
fd
,
u64
dir_id
,
u64
objid
,
char
*
name
,
int
name_len
);
u16
name_len
);
extern
int
btrfs_list_get_path_rootid
(
int
fd
,
u64
*
treeid
);
extern
bool
is_btrfs_fs
(
const
char
*
path
);
extern
int
is_btrfs_subvol
(
const
char
*
path
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment