mirror of
https://github.com/schoebel/mars
synced 2024-12-23 15:12:28 +00:00
import mars-119.tgz
This commit is contained in:
parent
62ed7174e8
commit
866ac28322
9
Kconfig
9
Kconfig
@ -5,7 +5,7 @@ config MARS
|
||||
tristate "storage system MARS"
|
||||
default n
|
||||
---help---
|
||||
Experimental storage System.
|
||||
Experimental storage System. Only compile as modules!
|
||||
|
||||
config MARS_HUNG
|
||||
tristate "hangup on kernel stacktrace (only for debugging)"
|
||||
@ -98,13 +98,6 @@ config MARS_COPY
|
||||
---help---
|
||||
Experimental storage System.
|
||||
|
||||
config MARS_TEST
|
||||
tristate "provisionary TESTBED"
|
||||
depends on MARS
|
||||
default m
|
||||
---help---
|
||||
Experimental storage System.
|
||||
|
||||
config MARS_LIGHT
|
||||
tristate "MARS Light main"
|
||||
depends on MARS
|
||||
|
11
Makefile
11
Makefile
@ -2,8 +2,10 @@
|
||||
# Makefile for MARS
|
||||
#
|
||||
|
||||
obj-$(CONFIG_MARS) += brick.o lib_log.o \
|
||||
mars_generic.o mars_net.o mars_proc.o
|
||||
obj-$(CONFIG_MARS) += brick.o \
|
||||
mars_generic.o sy_old/sy_generic.o \
|
||||
mars_net.o sy_old/sy_net.o \
|
||||
sy_old/mars_proc.o
|
||||
obj-$(CONFIG_MARS_DUMMY) += mars_dummy.o
|
||||
obj-$(CONFIG_MARS_CHECK) += mars_check.o
|
||||
obj-$(CONFIG_MARS_IF) += mars_if.o
|
||||
@ -12,13 +14,12 @@ obj-$(CONFIG_MARS_AIO) += mars_aio.o
|
||||
obj-$(CONFIG_MARS_SIO) += mars_sio.o
|
||||
obj-$(CONFIG_MARS_BUF) += mars_buf.o
|
||||
obj-$(CONFIG_MARS_USEBUF) += mars_usebuf.o
|
||||
obj-$(CONFIG_MARS_TRANS_LOGGER) += mars_trans_logger.o
|
||||
obj-$(CONFIG_MARS_TRANS_LOGGER) += mars_trans_logger.o lib_log.o
|
||||
obj-$(CONFIG_MARS_SERVER) += mars_server.o
|
||||
obj-$(CONFIG_MARS_CLIENT) += mars_client.o
|
||||
obj-$(CONFIG_MARS_COPY) += mars_copy.o
|
||||
|
||||
obj-$(CONFIG_MARS_TEST) += mars_test.o
|
||||
obj-$(CONFIG_MARS_LIGHT) += mars_light.o
|
||||
obj-$(CONFIG_MARS_LIGHT) += sy_old/mars_light.o
|
||||
|
||||
#mars-objs := mars_generic.o
|
||||
|
||||
|
135
mars.h
135
mars.h
@ -9,6 +9,8 @@
|
||||
|
||||
#define msleep msleep_interruptible
|
||||
|
||||
extern long long mars_global_memlimit;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// include the generic brick infrastructure
|
||||
@ -313,135 +315,22 @@ static const struct generic_aspect_type *BRICK##_aspect_types[BRICK_OBJ_MAX] = {
|
||||
|
||||
extern const struct meta mars_info_meta[];
|
||||
extern const struct meta mars_mref_meta[];
|
||||
|
||||
extern int mars_digest_size;
|
||||
extern void mars_digest(void *digest, void *data, int len);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern long long mars_global_memlimit;
|
||||
|
||||
extern struct mars_global *mars_global;
|
||||
|
||||
extern void _mars_trigger(void);
|
||||
#define mars_trigger() do { MARS_INF("trigger...\n"); _mars_trigger(); } while (0)
|
||||
extern int mars_power_button(struct mars_brick *brick, bool val, bool force_off);
|
||||
extern void mars_power_led_on(struct mars_brick *brick, bool val);
|
||||
extern void mars_power_led_off(struct mars_brick *brick, bool val);
|
||||
|
||||
extern int mars_power_button_recursive(struct mars_brick *brick, bool val, bool force_off, int timeout);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef _STRATEGY // call this only in strategy bricks, never in ordinary bricks
|
||||
|
||||
#define MARS_ARGV_MAX 4
|
||||
#define MARS_PATH_MAX 256
|
||||
|
||||
extern char *my_id(void);
|
||||
|
||||
#define MARS_DENT(TYPE) \
|
||||
struct list_head dent_link; \
|
||||
struct list_head brick_list; \
|
||||
struct TYPE *d_parent; \
|
||||
char *d_argv[MARS_ARGV_MAX]; /* for internal use, will be automatically deallocated*/ \
|
||||
char *d_args; /* ditto uninterpreted */ \
|
||||
char *d_name; /* current path component */ \
|
||||
char *d_rest; /* some "meaningful" rest of d_name*/ \
|
||||
char *d_path; /* full absolute path */ \
|
||||
int d_namelen; \
|
||||
int d_pathlen; \
|
||||
int d_depth; \
|
||||
unsigned int d_type; /* from readdir() => often DT_UNKNOWN => don't rely on it, use new_stat.mode instead */ \
|
||||
int d_class; /* for pre-grouping order */ \
|
||||
int d_serial; /* for pre-grouping order */ \
|
||||
int d_version; /* dynamic programming per call of mars_ent_work() */ \
|
||||
char d_once_error; \
|
||||
bool d_killme; \
|
||||
struct kstat new_stat; \
|
||||
struct kstat old_stat; \
|
||||
char *new_link; \
|
||||
char *old_link; \
|
||||
struct mars_global *d_global; \
|
||||
int d_logfile_serial; \
|
||||
void *d_private;
|
||||
|
||||
struct mars_dent {
|
||||
MARS_DENT(mars_dent);
|
||||
};
|
||||
|
||||
extern const struct meta mars_timespec_meta[];
|
||||
extern const struct meta mars_kstat_meta[];
|
||||
extern const struct meta mars_dent_meta[];
|
||||
|
||||
struct mars_global {
|
||||
struct rw_semaphore dent_mutex;
|
||||
struct rw_semaphore brick_mutex;
|
||||
struct generic_switch global_power;
|
||||
struct list_head dent_anchor;
|
||||
struct list_head brick_anchor;
|
||||
volatile bool main_trigger;
|
||||
wait_queue_head_t main_event;
|
||||
//void *private;
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef int (*mars_dent_checker)(struct mars_dent *parent, const char *name, int namlen, unsigned int d_type, int *prefix, int *serial);
|
||||
typedef int (*mars_dent_worker)(struct mars_global *global, struct mars_dent *dent, bool direction);
|
||||
#ifdef _STRATEGY
|
||||
#include "sy_old/strategy.h"
|
||||
#endif
|
||||
|
||||
extern int mars_dent_work(struct mars_global *global, char *dirname, int allocsize, mars_dent_checker checker, mars_dent_worker worker, void *buf, int maxdepth);
|
||||
extern struct mars_dent *mars_find_dent(struct mars_global *global, const char *path);
|
||||
extern void mars_kill_dent(struct mars_dent *dent);
|
||||
extern void mars_free_dent(struct mars_dent *dent);
|
||||
extern void mars_free_dent_all(struct list_head *anchor);
|
||||
|
||||
// low-level brick instantiation
|
||||
|
||||
extern struct mars_brick *mars_find_brick(struct mars_global *global, const void *brick_type, const char *path);
|
||||
extern struct mars_brick *mars_make_brick(struct mars_global *global, struct mars_dent *belongs, const void *_brick_type, const char *path, const char *name);
|
||||
extern int mars_free_brick(struct mars_brick *brick);
|
||||
extern int mars_kill_brick(struct mars_brick *brick);
|
||||
|
||||
// mid-level brick instantiation (identity is based on path strings)
|
||||
|
||||
extern char *vpath_make(const char *fmt, va_list *args);
|
||||
extern char *path_make(const char *fmt, ...);
|
||||
extern char *backskip_replace(const char *path, char delim, bool insert, const char *fmt, ...);
|
||||
|
||||
extern struct mars_brick *path_find_brick(struct mars_global *global, const void *brick_type, const char *fmt, ...);
|
||||
|
||||
/* Create a new brick and connect its inputs to a set of predecessors.
|
||||
* When @timeout > 0, switch on the brick as well as its predecessors.
|
||||
extern void mars_power_led_on(struct generic_brick *brick, bool val);
|
||||
extern void mars_power_led_off(struct generic_brick *brick, bool val);
|
||||
/* this should disappear!
|
||||
*/
|
||||
extern struct mars_brick *make_brick_all(
|
||||
struct mars_global *global,
|
||||
struct mars_dent *belongs,
|
||||
void (*setup_fn)(struct mars_brick *brick, void *private),
|
||||
void *private,
|
||||
int timeout,
|
||||
const char *new_name,
|
||||
const struct generic_brick_type *new_brick_type,
|
||||
const struct generic_brick_type *prev_brick_type[],
|
||||
const char *switch_fmt,
|
||||
const char *new_fmt,
|
||||
const char *prev_fmt[],
|
||||
int prev_count,
|
||||
...
|
||||
);
|
||||
extern void (*_mars_trigger)(void);
|
||||
#define mars_trigger() do { MARS_INF("trigger...\n"); if (_mars_trigger) _mars_trigger(); } while (0)
|
||||
|
||||
// general MARS infrastructure
|
||||
|
||||
#define MARS_ERR_ONCE(dent, args...) if (!dent->d_once_error++) MARS_ERR(args)
|
||||
|
||||
/* General fs wrappers (for abstraction)
|
||||
*/
|
||||
extern int mars_stat(const char *path, struct kstat *stat, bool use_lstat);
|
||||
extern int mars_mkdir(const char *path);
|
||||
extern int mars_symlink(const char *oldpath, const char *newpath, const struct timespec *stamp, uid_t uid);
|
||||
extern int mars_rename(const char *oldpath, const char *newpath);
|
||||
extern int mars_chmod(const char *path, mode_t mode);
|
||||
extern int mars_lchown(const char *path, uid_t uid);
|
||||
|
||||
#endif // _STRATEGY
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/* Some special brick types for avoidance of cyclic references.
|
||||
*
|
||||
|
1276
mars_generic.c
1276
mars_generic.c
File diff suppressed because it is too large
Load Diff
97
mars_net.c
97
mars_net.c
@ -8,10 +8,12 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#define _STRATEGY
|
||||
#include "mars.h"
|
||||
#include "mars_net.h"
|
||||
|
||||
static
|
||||
void mars_check_meta(const struct meta *meta, void *data);
|
||||
|
||||
/* Low-level network traffic
|
||||
*/
|
||||
|
||||
@ -32,33 +34,6 @@ struct mars_tcp_params default_tcp_params = {
|
||||
};
|
||||
EXPORT_SYMBOL(default_tcp_params);
|
||||
|
||||
char *mars_translate_hostname(struct mars_global *global, const char *name)
|
||||
{
|
||||
const char *res = name;
|
||||
struct mars_dent *test;
|
||||
char *tmp;
|
||||
|
||||
if (unlikely(!global)) {
|
||||
goto done;
|
||||
}
|
||||
tmp = path_make("/mars/ips/ip-%s", name);
|
||||
if (unlikely(!tmp)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
test = mars_find_dent(global, tmp);
|
||||
if (test && test->new_link) {
|
||||
MARS_DBG("'%s' => '%s'\n", tmp, test->new_link);
|
||||
res = test->new_link;
|
||||
}
|
||||
kfree(tmp);
|
||||
|
||||
done:
|
||||
return kstrdup(res, GFP_MARS);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_translate_hostname);
|
||||
|
||||
|
||||
static void _check(int status)
|
||||
{
|
||||
if (status < 0) {
|
||||
@ -79,7 +54,11 @@ int mars_create_sockaddr(struct sockaddr_storage *addr, const char *spec)
|
||||
|
||||
/* Try to translate hostnames to IPs if possible.
|
||||
*/
|
||||
new_spec = mars_translate_hostname(mars_global, spec);
|
||||
if (mars_translate_hostname) {
|
||||
new_spec = mars_translate_hostname(spec);
|
||||
} else {
|
||||
new_spec = kstrdup(spec, GFP_MARS);
|
||||
}
|
||||
tmp_spec = new_spec;
|
||||
|
||||
/* This is PROVISIONARY!
|
||||
@ -335,12 +314,7 @@ int _mars_send_struct(struct socket **sock, void *data, const struct meta *meta,
|
||||
|
||||
/* Automatically keep the lamport clock correct.
|
||||
*/
|
||||
if (meta == mars_cmd_meta) {
|
||||
struct timespec *stamp = &((struct mars_cmd*)data)->cmd_stamp;
|
||||
get_lamport(stamp);
|
||||
} else if (meta == mars_timespec_meta) {
|
||||
set_lamport(data);
|
||||
}
|
||||
mars_check_meta(meta, data);
|
||||
|
||||
status = 0;
|
||||
switch (meta->field_type) {
|
||||
@ -544,8 +518,7 @@ int _mars_recv_struct(struct socket **sock, void *data, const struct meta *meta,
|
||||
done:
|
||||
if (status >= 0) {
|
||||
status = count;
|
||||
if (meta == mars_timespec_meta)
|
||||
set_lamport(data);
|
||||
mars_check_meta(meta, data);
|
||||
} else {
|
||||
MARS_WRN("status = %d\n", status);
|
||||
}
|
||||
@ -573,46 +546,19 @@ const struct meta mars_cmd_meta[] = {
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(mars_cmd_meta);
|
||||
|
||||
int mars_send_dent_list(struct socket **sock, struct list_head *anchor)
|
||||
static
|
||||
void mars_check_meta(const struct meta *meta, void *data)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
struct mars_dent *dent;
|
||||
int status = 0;
|
||||
for (tmp = anchor->next; tmp != anchor; tmp = tmp->next) {
|
||||
dent = container_of(tmp, struct mars_dent, dent_link);
|
||||
status = mars_send_struct(sock, dent, mars_dent_meta);
|
||||
if (status < 0)
|
||||
break;
|
||||
/* Automatically keep the lamport clock correct.
|
||||
*/
|
||||
if (meta == mars_cmd_meta) {
|
||||
struct timespec *stamp = &((struct mars_cmd*)data)->cmd_stamp;
|
||||
get_lamport(stamp);
|
||||
} else if (meta == mars_timespec_meta) {
|
||||
set_lamport(data);
|
||||
}
|
||||
if (status >= 0) { // send EOF
|
||||
status = mars_send_struct(sock, NULL, mars_dent_meta);
|
||||
}
|
||||
return status;
|
||||
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_send_dent_list);
|
||||
|
||||
int mars_recv_dent_list(struct socket **sock, struct list_head *anchor)
|
||||
{
|
||||
int status;
|
||||
for (;;) {
|
||||
struct mars_dent *dent = kzalloc(sizeof(struct mars_dent), GFP_MARS);
|
||||
if (!dent)
|
||||
return -ENOMEM;
|
||||
|
||||
//MARS_IO("\n");
|
||||
|
||||
status = mars_recv_struct(sock, dent, mars_dent_meta);
|
||||
if (status <= 0) {
|
||||
kfree(dent);
|
||||
goto done;
|
||||
}
|
||||
list_add_tail(&dent->dent_link, anchor);
|
||||
INIT_LIST_HEAD(&dent->brick_list);
|
||||
}
|
||||
done:
|
||||
return status;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_recv_dent_list);
|
||||
|
||||
|
||||
int mars_send_mref(struct socket **sock, struct mref_object *mref)
|
||||
@ -705,6 +651,9 @@ EXPORT_SYMBOL_GPL(mars_recv_cb);
|
||||
|
||||
////////////////// module init stuff /////////////////////////
|
||||
|
||||
char *(*mars_translate_hostname)(const char *name) = NULL;
|
||||
EXPORT_SYMBOL_GPL(mars_translate_hostname);
|
||||
|
||||
static int __init _init_net(void)
|
||||
{
|
||||
MARS_INF("init_net()\n");
|
||||
|
@ -44,7 +44,7 @@ struct mars_cmd {
|
||||
|
||||
extern const struct meta mars_cmd_meta[];
|
||||
|
||||
extern char *mars_translate_hostname(struct mars_global *global, const char *name);
|
||||
extern char *(*mars_translate_hostname)(const char *name);
|
||||
|
||||
/* Low-level network traffic
|
||||
*/
|
||||
|
5
sy_old/README
Normal file
5
sy_old/README
Normal file
@ -0,0 +1,5 @@
|
||||
This is ugly code from a first prototype trial.
|
||||
It will disappear as soon as the new strategy layer has been
|
||||
implemented. The new system will use an interpreter for automated
|
||||
pattern matching and triggering actions, in a much more generic
|
||||
fashion than hand-crafted here.
|
@ -14,20 +14,19 @@
|
||||
#include <linux/genhd.h>
|
||||
#include <linux/blkdev.h>
|
||||
|
||||
#define _STRATEGY
|
||||
#include "mars.h"
|
||||
#include "strategy.h"
|
||||
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
// used brick types
|
||||
#include "mars_server.h"
|
||||
#include "mars_client.h"
|
||||
#include "mars_copy.h"
|
||||
#include "mars_bio.h"
|
||||
#include "mars_aio.h"
|
||||
#include "mars_trans_logger.h"
|
||||
#include "mars_if.h"
|
||||
#include "../mars_server.h"
|
||||
#include "../mars_client.h"
|
||||
#include "../mars_copy.h"
|
||||
#include "../mars_bio.h"
|
||||
#include "../mars_aio.h"
|
||||
#include "../mars_trans_logger.h"
|
||||
#include "../mars_if.h"
|
||||
|
||||
#if 0
|
||||
#define inline __attribute__((__noinline__))
|
||||
@ -788,7 +787,7 @@ int remote_thread(void *data)
|
||||
if (!peer)
|
||||
return -1;
|
||||
|
||||
real_peer = mars_translate_hostname(peer->global, peer->peer);
|
||||
real_peer = mars_translate_hostname(peer->peer);
|
||||
MARS_INF("-------- remote thread starting on peer '%s' (%s)\n", peer->peer, real_peer);
|
||||
|
||||
//fake_mm();
|
@ -11,8 +11,7 @@
|
||||
#include <linux/sysctl.h>
|
||||
#include <linux/uaccess.h>
|
||||
|
||||
#define _STRATEGY
|
||||
#include "mars.h"
|
||||
#include "strategy.h"
|
||||
#include "mars_proc.h"
|
||||
|
||||
mars_info_fn mars_info = NULL;
|
@ -2,8 +2,6 @@
|
||||
#ifndef MARS_PROC_H
|
||||
#define MARS_PROC_H
|
||||
|
||||
#include "brick.h"
|
||||
|
||||
typedef char * (*mars_info_fn)(void);
|
||||
|
||||
extern mars_info_fn mars_info;
|
127
sy_old/strategy.h
Normal file
127
sy_old/strategy.h
Normal file
@ -0,0 +1,127 @@
|
||||
// (c) 2010 Thomas Schoebel-Theuer / 1&1 Internet AG
|
||||
// OLD CODE => will disappear!
|
||||
#ifndef _OLD_STRATEGY
|
||||
#define _OLD_STRATEGY
|
||||
|
||||
#define _STRATEGY // call this only in strategy bricks, never in ordinary bricks
|
||||
|
||||
#include "../mars.h"
|
||||
|
||||
#define MARS_ARGV_MAX 4
|
||||
#define MARS_PATH_MAX 256
|
||||
|
||||
extern char *my_id(void);
|
||||
|
||||
#define MARS_DENT(TYPE) \
|
||||
struct list_head dent_link; \
|
||||
struct list_head brick_list; \
|
||||
struct TYPE *d_parent; \
|
||||
char *d_argv[MARS_ARGV_MAX]; /* for internal use, will be automatically deallocated*/ \
|
||||
char *d_args; /* ditto uninterpreted */ \
|
||||
char *d_name; /* current path component */ \
|
||||
char *d_rest; /* some "meaningful" rest of d_name*/ \
|
||||
char *d_path; /* full absolute path */ \
|
||||
int d_namelen; \
|
||||
int d_pathlen; \
|
||||
int d_depth; \
|
||||
unsigned int d_type; /* from readdir() => often DT_UNKNOWN => don't rely on it, use new_stat.mode instead */ \
|
||||
int d_class; /* for pre-grouping order */ \
|
||||
int d_serial; /* for pre-grouping order */ \
|
||||
int d_version; /* dynamic programming per call of mars_ent_work() */ \
|
||||
char d_once_error; \
|
||||
bool d_killme; \
|
||||
struct kstat new_stat; \
|
||||
struct kstat old_stat; \
|
||||
char *new_link; \
|
||||
char *old_link; \
|
||||
struct mars_global *d_global; \
|
||||
int d_logfile_serial; \
|
||||
void *d_private;
|
||||
|
||||
struct mars_dent {
|
||||
MARS_DENT(mars_dent);
|
||||
};
|
||||
|
||||
extern const struct meta mars_kstat_meta[];
|
||||
extern const struct meta mars_dent_meta[];
|
||||
|
||||
struct mars_global {
|
||||
struct rw_semaphore dent_mutex;
|
||||
struct rw_semaphore brick_mutex;
|
||||
struct generic_switch global_power;
|
||||
struct list_head dent_anchor;
|
||||
struct list_head brick_anchor;
|
||||
volatile bool main_trigger;
|
||||
wait_queue_head_t main_event;
|
||||
//void *private;
|
||||
};
|
||||
|
||||
typedef int (*mars_dent_checker)(struct mars_dent *parent, const char *name, int namlen, unsigned int d_type, int *prefix, int *serial);
|
||||
typedef int (*mars_dent_worker)(struct mars_global *global, struct mars_dent *dent, bool direction);
|
||||
|
||||
extern int mars_dent_work(struct mars_global *global, char *dirname, int allocsize, mars_dent_checker checker, mars_dent_worker worker, void *buf, int maxdepth);
|
||||
extern struct mars_dent *mars_find_dent(struct mars_global *global, const char *path);
|
||||
extern void mars_kill_dent(struct mars_dent *dent);
|
||||
extern void mars_free_dent(struct mars_dent *dent);
|
||||
extern void mars_free_dent_all(struct list_head *anchor);
|
||||
|
||||
// low-level brick instantiation
|
||||
|
||||
extern struct mars_brick *mars_find_brick(struct mars_global *global, const void *brick_type, const char *path);
|
||||
extern struct mars_brick *mars_make_brick(struct mars_global *global, struct mars_dent *belongs, const void *_brick_type, const char *path, const char *name);
|
||||
extern int mars_free_brick(struct mars_brick *brick);
|
||||
extern int mars_kill_brick(struct mars_brick *brick);
|
||||
|
||||
// mid-level brick instantiation (identity is based on path strings)
|
||||
|
||||
extern char *vpath_make(const char *fmt, va_list *args);
|
||||
extern char *path_make(const char *fmt, ...);
|
||||
extern char *backskip_replace(const char *path, char delim, bool insert, const char *fmt, ...);
|
||||
|
||||
extern struct mars_brick *path_find_brick(struct mars_global *global, const void *brick_type, const char *fmt, ...);
|
||||
|
||||
/* Create a new brick and connect its inputs to a set of predecessors.
|
||||
* When @timeout > 0, switch on the brick as well as its predecessors.
|
||||
*/
|
||||
extern struct mars_brick *make_brick_all(
|
||||
struct mars_global *global,
|
||||
struct mars_dent *belongs,
|
||||
void (*setup_fn)(struct mars_brick *brick, void *private),
|
||||
void *private,
|
||||
int timeout,
|
||||
const char *new_name,
|
||||
const struct generic_brick_type *new_brick_type,
|
||||
const struct generic_brick_type *prev_brick_type[],
|
||||
const char *switch_fmt,
|
||||
const char *new_fmt,
|
||||
const char *prev_fmt[],
|
||||
int prev_count,
|
||||
...
|
||||
);
|
||||
|
||||
// general MARS infrastructure
|
||||
|
||||
#define MARS_ERR_ONCE(dent, args...) if (!dent->d_once_error++) MARS_ERR(args)
|
||||
|
||||
/* General fs wrappers (for abstraction)
|
||||
*/
|
||||
extern int mars_stat(const char *path, struct kstat *stat, bool use_lstat);
|
||||
extern int mars_mkdir(const char *path);
|
||||
extern int mars_symlink(const char *oldpath, const char *newpath, const struct timespec *stamp, uid_t uid);
|
||||
extern int mars_rename(const char *oldpath, const char *newpath);
|
||||
extern int mars_chmod(const char *path, mode_t mode);
|
||||
extern int mars_lchown(const char *path, uid_t uid);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern struct mars_global *mars_global;
|
||||
|
||||
extern int mars_power_button(struct mars_brick *brick, bool val, bool force_off);
|
||||
extern int mars_power_button_recursive(struct mars_brick *brick, bool val, bool force_off, int timeout);
|
||||
|
||||
/* Crypto stuff
|
||||
*/
|
||||
extern int mars_digest_size;
|
||||
extern void mars_digest(void *digest, void *data, int len);
|
||||
#endif
|
||||
|
1225
sy_old/sy_generic.c
Normal file
1225
sy_old/sy_generic.c
Normal file
File diff suppressed because it is too large
Load Diff
103
sy_old/sy_net.c
Normal file
103
sy_old/sy_net.c
Normal file
@ -0,0 +1,103 @@
|
||||
// (c) 2011 Thomas Schoebel-Theuer / 1&1 Internet AG
|
||||
|
||||
//#define BRICK_DEBUGGING
|
||||
//#define MARS_DEBUGGING
|
||||
//#define IO_DEBUGGING
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include "strategy.h"
|
||||
#include "../mars_net.h"
|
||||
|
||||
static
|
||||
char *_mars_translate_hostname(const char *name)
|
||||
{
|
||||
struct mars_global *global = mars_global;
|
||||
const char *res = name;
|
||||
struct mars_dent *test;
|
||||
char *tmp;
|
||||
|
||||
if (unlikely(!global)) {
|
||||
goto done;
|
||||
}
|
||||
tmp = path_make("/mars/ips/ip-%s", name);
|
||||
if (unlikely(!tmp)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
test = mars_find_dent(global, tmp);
|
||||
if (test && test->new_link) {
|
||||
MARS_DBG("'%s' => '%s'\n", tmp, test->new_link);
|
||||
res = test->new_link;
|
||||
}
|
||||
kfree(tmp);
|
||||
|
||||
done:
|
||||
return kstrdup(res, GFP_MARS);
|
||||
}
|
||||
|
||||
int mars_send_dent_list(struct socket **sock, struct list_head *anchor)
|
||||
{
|
||||
struct list_head *tmp;
|
||||
struct mars_dent *dent;
|
||||
int status = 0;
|
||||
for (tmp = anchor->next; tmp != anchor; tmp = tmp->next) {
|
||||
dent = container_of(tmp, struct mars_dent, dent_link);
|
||||
status = mars_send_struct(sock, dent, mars_dent_meta);
|
||||
if (status < 0)
|
||||
break;
|
||||
}
|
||||
if (status >= 0) { // send EOF
|
||||
status = mars_send_struct(sock, NULL, mars_dent_meta);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_send_dent_list);
|
||||
|
||||
int mars_recv_dent_list(struct socket **sock, struct list_head *anchor)
|
||||
{
|
||||
int status;
|
||||
for (;;) {
|
||||
struct mars_dent *dent = kzalloc(sizeof(struct mars_dent), GFP_MARS);
|
||||
if (!dent)
|
||||
return -ENOMEM;
|
||||
|
||||
//MARS_IO("\n");
|
||||
|
||||
status = mars_recv_struct(sock, dent, mars_dent_meta);
|
||||
if (status <= 0) {
|
||||
kfree(dent);
|
||||
goto done;
|
||||
}
|
||||
list_add_tail(&dent->dent_link, anchor);
|
||||
INIT_LIST_HEAD(&dent->brick_list);
|
||||
}
|
||||
done:
|
||||
return status;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mars_recv_dent_list);
|
||||
|
||||
|
||||
////////////////// module init stuff /////////////////////////
|
||||
|
||||
|
||||
static int __init _init_sy_net(void)
|
||||
{
|
||||
MARS_INF("init_sy_net()\n");
|
||||
mars_translate_hostname = _mars_translate_hostname;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit _exit_sy_net(void)
|
||||
{
|
||||
MARS_INF("exit_sy_net()\n");
|
||||
}
|
||||
|
||||
MODULE_DESCRIPTION("MARS network infrastructure");
|
||||
MODULE_AUTHOR("Thomas Schoebel-Theuer <tst@1und1.de>");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(_init_sy_net);
|
||||
module_exit(_exit_sy_net);
|
Loading…
Reference in New Issue
Block a user