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
2b670dfe
Commit
2b670dfe
authored
Aug 18, 2018
by
2xsec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage_utils: move duplicated function from tools
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
34a10bfa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
71 deletions
+37
-71
storage_utils.c
src/lxc/storage/storage_utils.c
+35
-0
storage_utils.h
src/lxc/storage/storage_utils.h
+1
-0
lxc_copy.c
src/lxc/tools/lxc_copy.c
+1
-35
lxc_create.c
src/lxc/tools/lxc_create.c
+0
-36
No files found.
src/lxc/storage/storage_utils.c
View file @
2b670dfe
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
*/
*/
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <ctype.h>
#include <dirent.h>
#include <dirent.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
...
@@ -457,6 +458,40 @@ bool unpriv_snap_allowed(struct lxc_storage *b, const char *t, bool snap,
...
@@ -457,6 +458,40 @@ bool unpriv_snap_allowed(struct lxc_storage *b, const char *t, bool snap,
return
false
;
return
false
;
}
}
uint64_t
get_fssize
(
char
*
s
)
{
uint64_t
ret
;
char
*
end
;
ret
=
strtoull
(
s
,
&
end
,
0
);
if
(
end
==
s
)
{
ERROR
(
"Invalid blockdev size '%s', using default size"
,
s
);
return
0
;
}
while
(
isblank
(
*
end
))
end
++
;
if
(
*
end
==
'\0'
)
{
ret
*=
1024ULL
*
1024ULL
;
/* MB by default */
}
else
if
(
*
end
==
'b'
||
*
end
==
'B'
)
{
ret
*=
1ULL
;
}
else
if
(
*
end
==
'k'
||
*
end
==
'K'
)
{
ret
*=
1024ULL
;
}
else
if
(
*
end
==
'm'
||
*
end
==
'M'
)
{
ret
*=
1024ULL
*
1024ULL
;
}
else
if
(
*
end
==
'g'
||
*
end
==
'G'
)
{
ret
*=
1024ULL
*
1024ULL
*
1024ULL
;
}
else
if
(
*
end
==
't'
||
*
end
==
'T'
)
{
ret
*=
1024ULL
*
1024ULL
*
1024ULL
*
1024ULL
;
}
else
{
ERROR
(
"Invalid blockdev unit size '%c' in '%s', using default size"
,
*
end
,
s
);
return
0
;
}
return
ret
;
}
bool
is_valid_storage_type
(
const
char
*
type
)
bool
is_valid_storage_type
(
const
char
*
type
)
{
{
if
(
strcmp
(
type
,
"dir"
)
==
0
||
if
(
strcmp
(
type
,
"dir"
)
==
0
||
...
...
src/lxc/storage/storage_utils.h
View file @
2b670dfe
...
@@ -48,6 +48,7 @@ extern int find_fstype_cb(char *buffer, void *data);
...
@@ -48,6 +48,7 @@ extern int find_fstype_cb(char *buffer, void *data);
extern
const
char
*
linkderef
(
const
char
*
path
,
char
*
dest
);
extern
const
char
*
linkderef
(
const
char
*
path
,
char
*
dest
);
extern
bool
unpriv_snap_allowed
(
struct
lxc_storage
*
b
,
const
char
*
t
,
bool
snap
,
extern
bool
unpriv_snap_allowed
(
struct
lxc_storage
*
b
,
const
char
*
t
,
bool
snap
,
bool
maybesnap
);
bool
maybesnap
);
extern
uint64_t
get_fssize
(
char
*
s
);
extern
bool
is_valid_storage_type
(
const
char
*
type
);
extern
bool
is_valid_storage_type
(
const
char
*
type
);
extern
int
storage_destroy_wrapper
(
void
*
data
);
extern
int
storage_destroy_wrapper
(
void
*
data
);
...
...
src/lxc/tools/lxc_copy.c
View file @
2b670dfe
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
*/
*/
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <ctype.h>
#include <errno.h>
#include <errno.h>
#include <fcntl.h>
#include <fcntl.h>
#include <getopt.h>
#include <getopt.h>
...
@@ -37,6 +36,7 @@
...
@@ -37,6 +36,7 @@
#include "arguments.h"
#include "arguments.h"
#include "log.h"
#include "log.h"
#include "storage_utils.h"
#include "utils.h"
#include "utils.h"
#ifndef HAVE_GETSUBOPT
#ifndef HAVE_GETSUBOPT
...
@@ -143,7 +143,6 @@ static int do_clone_rename(struct lxc_container *c, char *newname);
...
@@ -143,7 +143,6 @@ static int do_clone_rename(struct lxc_container *c, char *newname);
static
int
do_clone_task
(
struct
lxc_container
*
c
,
enum
task
task
,
int
flags
,
static
int
do_clone_task
(
struct
lxc_container
*
c
,
enum
task
task
,
int
flags
,
char
**
args
);
char
**
args
);
static
void
free_mnts
(
void
);
static
void
free_mnts
(
void
);
static
uint64_t
get_fssize
(
char
*
s
);
/* Place an ephemeral container started with -e flag on a tmpfs. Restrictions
/* Place an ephemeral container started with -e flag on a tmpfs. Restrictions
* are that you cannot request the data to be kept while placing the container
* are that you cannot request the data to be kept while placing the container
...
@@ -538,39 +537,6 @@ static void free_mnts()
...
@@ -538,39 +537,6 @@ static void free_mnts()
mnt_table_size
=
0
;
mnt_table_size
=
0
;
}
}
/* we pass fssize in bytes */
static
uint64_t
get_fssize
(
char
*
s
)
{
uint64_t
ret
;
char
*
end
;
ret
=
strtoull
(
s
,
&
end
,
0
);
if
(
end
==
s
)
{
ERROR
(
"Invalid blockdev size '%s', using default size"
,
s
);
return
0
;
}
while
(
isblank
(
*
end
))
end
++
;
if
(
*
end
==
'\0'
)
{
ret
*=
1024ULL
*
1024ULL
;
/* MB by default */
}
else
if
(
*
end
==
'b'
||
*
end
==
'B'
)
{
ret
*=
1ULL
;
}
else
if
(
*
end
==
'k'
||
*
end
==
'K'
)
{
ret
*=
1024ULL
;
}
else
if
(
*
end
==
'm'
||
*
end
==
'M'
)
{
ret
*=
1024ULL
*
1024ULL
;
}
else
if
(
*
end
==
'g'
||
*
end
==
'G'
)
{
ret
*=
1024ULL
*
1024ULL
*
1024ULL
;
}
else
if
(
*
end
==
't'
||
*
end
==
'T'
)
{
ret
*=
1024ULL
*
1024ULL
*
1024ULL
*
1024ULL
;
}
else
{
ERROR
(
"Invalid blockdev unit size '%c' in '%s', "
"using default size"
,
*
end
,
s
);
return
0
;
}
return
ret
;
}
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
)
{
{
char
*
subopts
=
NULL
;
char
*
subopts
=
NULL
;
...
...
src/lxc/tools/lxc_create.c
View file @
2b670dfe
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
*/
*/
#define _GNU_SOURCE
#define _GNU_SOURCE
#include <ctype.h>
#include <fcntl.h>
#include <fcntl.h>
#include <libgen.h>
#include <libgen.h>
#include <stdint.h>
#include <stdint.h>
...
@@ -37,7 +36,6 @@
...
@@ -37,7 +36,6 @@
lxc_log_define
(
lxc_create
,
lxc
);
lxc_log_define
(
lxc_create
,
lxc
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
int
my_parser
(
struct
lxc_arguments
*
args
,
int
c
,
char
*
arg
);
static
uint64_t
get_fssize
(
char
*
s
);
static
void
create_helpfn
(
const
struct
lxc_arguments
*
args
);
static
void
create_helpfn
(
const
struct
lxc_arguments
*
args
);
static
bool
validate_bdev_args
(
struct
lxc_arguments
*
args
);
static
bool
validate_bdev_args
(
struct
lxc_arguments
*
args
);
...
@@ -146,40 +144,6 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
...
@@ -146,40 +144,6 @@ static int my_parser(struct lxc_arguments *args, int c, char *arg)
return
0
;
return
0
;
}
}
static
uint64_t
get_fssize
(
char
*
s
)
{
uint64_t
ret
;
char
*
end
;
ret
=
strtoull
(
s
,
&
end
,
0
);
if
(
end
==
s
)
{
ERROR
(
"Invalid blockdev size '%s', using default size"
,
s
);
return
0
;
}
while
(
isblank
(
*
end
))
end
++
;
if
(
*
end
==
'\0'
)
{
ret
*=
1024ULL
*
1024ULL
;
/* MB by default */
}
else
if
(
*
end
==
'b'
||
*
end
==
'B'
)
{
ret
*=
1ULL
;
}
else
if
(
*
end
==
'k'
||
*
end
==
'K'
)
{
ret
*=
1024ULL
;
}
else
if
(
*
end
==
'm'
||
*
end
==
'M'
)
{
ret
*=
1024ULL
*
1024ULL
;
}
else
if
(
*
end
==
'g'
||
*
end
==
'G'
)
{
ret
*=
1024ULL
*
1024ULL
*
1024ULL
;
}
else
if
(
*
end
==
't'
||
*
end
==
'T'
)
{
ret
*=
1024ULL
*
1024ULL
*
1024ULL
*
1024ULL
;
}
else
{
ERROR
(
"Invalid blockdev unit size '%c' in '%s', using default size"
,
*
end
,
s
);
return
0
;
}
return
ret
;
}
static
void
create_helpfn
(
const
struct
lxc_arguments
*
args
)
static
void
create_helpfn
(
const
struct
lxc_arguments
*
args
)
{
{
char
*
argv
[
3
],
*
path
;
char
*
argv
[
3
],
*
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