Exemple #1
0
int share_file_copy_cb(SHFL *src_file, SHFL *dest_file)
{
  shpeer_t *src_peer = shfs_inode_peer(src_file);
  int err;

  if (0 == strcmp(src_peer->label, "file")) {
    char path[PATH_MAX+1];

    /* set link to local-disk path. */
    sprintf(path, "%s", shfs_inode_path(src_file));
    err = shfs_ext_set(src_file, path);
    if (err)
      return (err);
  }

  /* perform file copy */
  err = shfs_file_copy(src_file, dest_file);
  if (err) {
    fprintf(sharetool_fout, "%s: error copying \"%s\" to \"%s\": %s [sherr %d].\n",
        process_path, shfs_filename(src_file), shfs_filename(dest_file),
        sherrstr(err), err);
    return (err);
  }

  if (!(run_flags & PFLAG_QUIET) && (run_flags & PFLAG_VERBOSE)) {
    fprintf(sharetool_fout, "%s: %s \"%s\" copied to %s \"%s\".\n",
        process_path,
        shfs_type_str(shfs_type(src_file)), shfs_filename(src_file),
        shfs_type_str(shfs_type(dest_file)), shfs_filename(dest_file)); 
  }

  return (0);
}
Exemple #2
0
int shfs_file_notify(shfs_ino_t *file)
{
  shfs_t *tree = file->tree;
  shbuf_t *buff;
  uint32_t mode; 
  int qid;
  int err;

  if (!file || !tree)
    return (0); /* done */

  qid = _shfs_file_qid();
  if (qid == -1)
    return (SHERR_IO);

  buff = shbuf_init();
  mode = TX_FILE;
  shbuf_cat(buff, &mode, sizeof(mode));
  shbuf_cat(buff, &tree->peer, sizeof(shpeer_t));
  shbuf_catstr(buff, shfs_inode_path(file));
  err = shmsg_write(qid, buff, NULL);
  shbuf_free(&buff);
  if (err)
    return (err);

  return (0);
}