[r109]: branches / smbnetfs-0.3 / src / main.c  Maximize  Restore  History

Download this file

128 lines (108 with data), 3.0 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <config.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>
#include <string.h>
#include <locale.h>
#include <signal.h>
#include <fuse/fuse.h>
#include "list.h"
#include "common.h"
#include "charset.h"
#include "auth.h"
#include "smbctx.h"
#include "smbitem.h"
#include "filestruct.h"
#include "function.h"
#include "event_thread.h"
#include "reconfigure.h"
extern FILE *stdlog;
char *mountpoint = NULL;
void sig_handler(int signum){
fprintf(stderr, "%d->%s: SIGILL or SIGSEGV received\n",
getpid(), __FUNCTION__);
if (stdlog != NULL) fprintf(stdlog, "%d->%s: SIGILL or SIGSEGV received\n",
getpid(), __FUNCTION__);
print_backtrace();
if (mountpoint != NULL) fuse_unmount(mountpoint);
exit(signum);
}
void parse_cmdline(int argc, char *argv[]){
int c;
int print_version = 0;
int get_help = 0;
opterr = 0;
while(1){
static struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0},
};
c = getopt_long(argc, argv, "-hV", long_options, NULL);
if (c == -1) break;
switch(c){
case 1:
if (mountpoint == NULL) mountpoint = optarg;
break;
case 'h':
get_help = 1;
break;
case 'V':
print_version = 1;
break;
default:
break;
}
}
optarg = NULL; optopt = '?'; optind = opterr = 1;
if (get_help || print_version){
if (print_version)
printf("%s version: %s\n", PACKAGE_NAME, PACKAGE_VERSION);
fuse_main(argc, argv, &smb_oper);
exit(0);
}
}
int main(int argc, char *argv[]){
struct sigaction siginfo;
setlocale(LC_ALL, "");
siginfo.sa_handler = sig_handler;
sigemptyset(&siginfo.sa_mask);
siginfo.sa_flags = SA_RESTART;
if (sigaction(SIGILL, &siginfo, NULL) < 0){
fprintf(stderr, "Can't set SIGILL handler\n");
return 1;
}
if (sigaction(SIGSEGV, &siginfo, NULL) < 0){
fprintf(stderr, "Can't set SIGSEGV handler\n");
return 1;
}
sigemptyset(&siginfo.sa_mask);
sigaddset(&siginfo.sa_mask, SIGHUP);
sigaddset(&siginfo.sa_mask, SIGALRM);
if (pthread_sigmask(SIG_BLOCK, &siginfo.sa_mask, NULL) != 0){
fprintf(stderr, "Can't block SIGHUP and SIGALRM signals.\n");
return 1;
}
parse_cmdline(argc, argv);
GetUserLogin();
GetConfigDir();
if (!charset_init()){
fprintf(stderr, "Fatal error: iconv initialization failed.\n");
exit(1);
}
if (chdir(config_dir) == 0){
if (!ReadConfigFile(config_file))
fprintf(stderr, "Can't read/find config file '%s/%s'\n", config_dir, config_file);
}else fprintf(stderr, "Config dir '%s' error (%s)\n", config_dir, strerror(errno));
AllocateSmbCtx();
SetEventHandlers(&smb_oper);
int ret = fuse_main(argc, argv, &smb_oper);
if (GetFastShutdown()) return ret;
DeleteOldSmbAuthData(time(NULL) + 10);
DeleteOldSmbItem(time(NULL) + 10, JOINED_TREE);
DestroyUnusedCtx();
print_file_handle_status();
return ret;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks