libgpo/gpo_filesync.c

ソースコードを見る。

データ構造

struct  sync_context

関数

static void gpo_sync_func (const char *mnt, file_info *info, const char *mask, void *state)
NTSTATUS gpo_copy_file (TALLOC_CTX *mem_ctx, struct cli_state *cli, const char *nt_path, const char *unix_path)
static NTSTATUS gpo_copy_dir (const char *unix_path)
static BOOL gpo_sync_files (struct sync_context *ctx)
NTSTATUS gpo_sync_directories (TALLOC_CTX *mem_ctx, struct cli_state *cli, const char *nt_path, const char *local_path)


関数

static void gpo_sync_func ( const char *  mnt,
file_info info,
const char *  mask,
void *  state 
) [static]

gpo_filesync.c128 行で定義されています。

参照先 ctxgpo_copy_dir()gpo_copy_file()gpo_sync_files()file_info::modefile_info::nament_errstr()resultstrequal()talloc_strdup().

参照元 gpo_sync_files().

00132 {
00133         NTSTATUS result;
00134         struct sync_context *ctx;
00135         fstring nt_filename, unix_filename;
00136         fstring nt_dir, unix_dir;
00137         char *old_nt_dir, *old_unix_dir;
00138 
00139         ctx = (struct sync_context *)state;
00140 
00141         if (strequal(info->name, ".") || strequal(info->name, "..")) {
00142                 return;
00143         }
00144 
00145         DEBUG(5,("gpo_sync_func: got mask: [%s], name: [%s]\n", 
00146                 mask, info->name));
00147 
00148         if (info->mode & aDIR) {
00149 
00150                 DEBUG(3,("got dir: [%s]\n", info->name));
00151 
00152                 fstrcpy(nt_dir, ctx->remote_path);
00153                 fstrcat(nt_dir, "\\");
00154                 fstrcat(nt_dir, info->name);
00155 
00156                 fstrcpy(unix_dir, ctx->local_path);
00157                 fstrcat(unix_dir, "/");
00158                 fstrcat(unix_dir, info->name);
00159 
00160                 result = gpo_copy_dir(unix_dir);
00161                 if (!NT_STATUS_IS_OK(result)) {
00162                         DEBUG(1,("failed to copy dir: %s\n", nt_errstr(result)));
00163                 }
00164 
00165                 old_nt_dir = ctx->remote_path;
00166                 ctx->remote_path = nt_dir;
00167                 
00168                 old_unix_dir = ctx->local_path;
00169                 ctx->local_path = talloc_strdup(ctx->mem_ctx, unix_dir);
00170 
00171                 pstrcpy(ctx->mask, nt_dir);
00172                 pstrcat(ctx->mask, "\\*");
00173 
00174                 if (!gpo_sync_files(ctx)) {
00175                         DEBUG(0,("could not sync files\n"));
00176                 }
00177 
00178                 ctx->remote_path = old_nt_dir;
00179                 ctx->local_path = old_unix_dir;
00180                 return;
00181         }
00182 
00183         DEBUG(3,("got file: [%s]\n", info->name));
00184 
00185         fstrcpy(nt_filename, ctx->remote_path);
00186         fstrcat(nt_filename, "\\");
00187         fstrcat(nt_filename, info->name);
00188 
00189         fstrcpy(unix_filename, ctx->local_path);
00190         fstrcat(unix_filename, "/");
00191         fstrcat(unix_filename, info->name);
00192 
00193         result = gpo_copy_file(ctx->mem_ctx, ctx->cli, nt_filename, unix_filename);
00194         if (!NT_STATUS_IS_OK(result)) {
00195                 DEBUG(1,("failed to copy file: %s\n", nt_errstr(result)));
00196         }
00197 }

NTSTATUS gpo_copy_file ( TALLOC_CTX mem_ctx,
struct cli_state cli,
const char *  nt_path,
const char *  unix_path 
)

gpo_filesync.c37 行で定義されています。

参照先 clicli_close()cli_open()cli_read()errnofdio_bufsizemap_nt_error_from_unix()resultsys_open().

参照元 ads_fetch_gpo_files()gpo_sync_func().

00041 {
00042         NTSTATUS result;
00043         int fnum;
00044         int fd = 0;
00045         char *data = NULL;
00046         static int io_bufsize = 64512;
00047         int read_size = io_bufsize;
00048         off_t start = 0;
00049         off_t nread = 0;
00050 
00051         if ((fnum = cli_open(cli, nt_path, O_RDONLY, DENY_NONE)) == -1) {
00052                 result = NT_STATUS_NO_SUCH_FILE;
00053                 goto out;
00054         }
00055 
00056         if ((fd = sys_open(unix_path, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
00057                 result = map_nt_error_from_unix(errno);
00058                 goto out;
00059         }
00060          
00061         if ((data = (char *)SMB_MALLOC(read_size)) == NULL) {
00062                 result = NT_STATUS_NO_MEMORY;
00063                 goto out;
00064         }
00065 
00066         while (1) {
00067 
00068                 int n = cli_read(cli, fnum, data, nread + start, read_size);
00069 
00070                 if (n <= 0)
00071                         break;
00072 
00073                 if (write(fd, data, n) != n) {
00074                         break;
00075                 }
00076 
00077                 nread += n;
00078         }
00079 
00080         result = NT_STATUS_OK;
00081 
00082  out:
00083         SAFE_FREE(data);
00084         if (fnum) {
00085                 cli_close(cli, fnum);
00086         }
00087         if (fd) {
00088                 close(fd);
00089         }
00090 
00091         return result;
00092 }

static NTSTATUS gpo_copy_dir ( const char *  unix_path  )  [static]

gpo_filesync.c98 行で定義されています。

参照先 errno.

参照元 gpo_sync_func().

00099 {
00100         if ((mkdir(unix_path, 0644)) < 0 && errno != EEXIST) {
00101                 return NT_STATUS_ACCESS_DENIED;
00102         }
00103 
00104         return NT_STATUS_OK;
00105 }

static BOOL gpo_sync_files ( struct sync_context ctx  )  [static]

gpo_filesync.c111 行で定義されています。

参照先 cli_errstr()cli_list()ctxgpo_sync_func().

参照元 gpo_sync_directories()gpo_sync_func().

00112 {
00113         DEBUG(3,("calling cli_list with mask: %s\n", ctx->mask));
00114 
00115         if (cli_list(ctx->cli, ctx->mask, ctx->attribute, gpo_sync_func, ctx) == -1) {
00116                 DEBUG(1,("listing [%s] failed with error: %s\n", 
00117                         ctx->mask, cli_errstr(ctx->cli)));
00118                 return False;
00119         }
00120 
00121         return True;
00122 }

NTSTATUS gpo_sync_directories ( TALLOC_CTX mem_ctx,
struct cli_state cli,
const char *  nt_path,
const char *  local_path 
)

gpo_filesync.c204 行で定義されています。

参照先 clictxgpo_sync_files().

参照元 ads_fetch_gpo_files().

00208 {
00209         struct sync_context ctx;
00210 
00211         ctx.mem_ctx     = mem_ctx;
00212         ctx.cli         = cli;
00213         ctx.remote_path = CONST_DISCARD(char *, nt_path);
00214         ctx.local_path  = CONST_DISCARD(char *, local_path);
00215         ctx.attribute   = (aSYSTEM | aHIDDEN | aDIR);
00216 
00217         pstrcpy(ctx.mask, nt_path);
00218         pstrcat(ctx.mask, "\\*");
00219 
00220         if (!gpo_sync_files(&ctx)) {
00221                 return NT_STATUS_NO_SUCH_FILE;
00222         }
00223 
00224         return NT_STATUS_OK;
00225 }


Sambaに対してSat Aug 29 21:23:42 2009に生成されました。  doxygen 1.4.7