68{
   74};
   75 
   76 
   82{
   87 
   92 
   97};
   98 
   99 
  107static int
  109{
  111 
  131 
  133}
  134 
  135 
  146{
  148 
  149#if defined(HAVE_STAT64) && \
  150  ! (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64)
  151  struct stat64 buf;
  152 
  153  if (0 != lstat64 (fn, &buf))
  154  {
  157  }
  158#else
  159  struct stat buf;
  160 
  161  if (0 != lstat (fn, &buf))
  162  {
  165  }
  166#endif
  168  {
  169    errno = EISDIR;
  171  }
  173  {
  175    if (NULL == realpath (fn, linkdst))
  176    {
  179    }
  181  }
  183    gfsd->
total += buf.st_size;
 
  184  if ((S_ISDIR (buf.st_mode)) && (0 == access (fn, X_OK)) &&
  186  {
  190                                    gfsd))
  192  }
  194}
  195 
  196 
  199{
  201}
  202 
  203 
  207{
  208  struct stat sbuf;
  209 
  210  if (0 != fstat (fh->
fd, &sbuf))
 
  212  *
size = sbuf.st_size;
 
  214}
  215 
  216 
  217off_t
  219                       off_t offset,
  221{
  222  static int t[] = { SEEK_SET, SEEK_CUR, SEEK_END };
 
  223 
  225  {
  226    errno = EINVAL;
  228  }
  229  return lseek (
h->fd, offset, 
t[whence]);
 
  230}
  231 
  232 
  236                       int include_symbolic_links,
  237                       int single_file_mode)
  238{
  241 
  249}
  250 
  251 
  254                                  uint64_t *dev,
  255                                  uint64_t *ino)
  256{
  257#if HAVE_STAT
  258  {
  259    struct stat sbuf;
  260 
  262    {
  264    }
  265    *ino = (uint64_t) sbuf.st_ino;
  266  }
  267#else
  268  *ino = 0;
  269#endif
  270#if HAVE_STATVFS
  271  {
  272    struct statvfs fbuf;
  273 
  275    {
  277    }
  278    *dev = (uint64_t) fbuf.f_fsid;
  279  }
  280#elif HAVE_STATFS
  281  {
  282    struct statfs fbuf;
  283 
  285    {
  287    }
  288    *dev =
  289      ((uint64_t) fbuf.f_fsid.val[0]) << 32 || ((uint64_t) fbuf.f_fsid.val[1]);
  290  }
  291#else
  292  *dev = 0;
  293#endif
  295}
  296 
  297 
  304static char *
  306{
  307  const char *tmpdir;
  308  char *tmpl;
  309  char *fn;
  310 
  311  if ((
t[0] != 
'/') && (
t[0] != 
'\\'))
 
  312  {
  313    
  314    tmpdir = 
getenv (
"TMPDIR");
 
  315    if (NULL == tmpdir)
  317    if (NULL == tmpdir)
  319    if (NULL == tmpdir)
  320      tmpdir = "/tmp";
  322  }
  323  else
  324  {
  326  }
  327  fn = tmpl;
  328  return fn;
  329}
  330 
  331 
  332void
  334                             int require_uid_match,
  335                             int require_gid_match)
  336{
  338 
  340    mode = S_IRUSR | S_IWUSR | S_IXUSR;
 
  342    mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP;
 
  343  else
  344    mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH
 
  345           | S_IWOTH | S_IXOTH;
  346  if (0 != chmod (fn, 
mode))
 
  348}
  349 
  350 
  351char *
  353{
  354  char *fn;
  355  mode_t omask;
  356 
  357  omask = umask (S_IWGRP | S_IWOTH | S_IRGRP | S_IROTH);
  359  if (fn != mkdtemp (fn))
  360  {
  363    umask (omask);
  364    return NULL;
  365  }
  366  umask (omask);
  367  return fn;
  368}
  369 
  370 
  371char *
  373{
  374  size_t slen;
  375  char *target;
  376  unsigned int num;
  377 
  378  slen = strlen (fil) + 20;
  380  num = 0;
  381 
  382#if HAVE_RENAMEAT2
  383  {
  384    int fd;
  385 
  386    do
  387    {
  389                       slen,
  390                       "%s.%u~",
  391                       fil,
  392                       num++);
  393      fd = open (target,
  394                 O_CREAT | O_EXCL,
  396    } while (-1 == fd);
  397    if (0 != renameat2 (AT_FDCWD,
  398                        fil,
  399                        AT_FDCWD,
  400                        target,
  401                        RENAME_EXCHANGE))
  402    {
  404                                "renameat2",
  405                                fil);
  407                    close (fd));
  408      return NULL;
  409    }
  411                  close (fd));
  412  }
  413#else
  414  do
  415  {
  417  }
  418  while (0 == access (target, F_OK));
  419  if (0 != rename (fil, target))
  420  {
  422    return NULL;
  423  }
  424#endif
  425  return target;
  426}
  427 
  428 
  429char *
  431{
  432  int fd;
  433  char *fn;
  434  mode_t omask;
  435 
  436  omask = umask (S_IWGRP | S_IWOTH | S_IRGRP | S_IROTH);
  438  if (-1 == (fd = mkstemp (fn)))
  439  {
  442    umask (omask);
  443    return NULL;
  444  }
  445  umask (omask);
  446  if (0 != close (fd))
  448  return fn;
  449}
  450 
  451 
  454{
  455  struct stat filestat;
  457 
  458  ret = stat (fil, &filestat);
 
  460  {
  461    if (errno != ENOENT)
  464  }
  465  if (! S_ISDIR (filestat.st_mode))
  466  {
  468         "A file already exits with the same name %s\n",
  469         fil);
  471  }
  473    ret = access (fil, R_OK | X_OK);
 
  474  else
  475    ret = access (fil, X_OK);
 
  477  {
  480  }
  482}
  483 
  484 
  494{
  495  struct stat filestat;
  497  char *rdir;
  498 
  500  if (rdir == NULL)
  502 
  503  ret = stat (rdir, &filestat);
 
  505  {
  506    if (errno != ENOENT)
  507    {
  511    }
  514  }
  515  if (! S_ISREG (filestat.st_mode))
  516  {
  519  }
  520  if (access (rdir, amode) < 0)
  521  {
  525  }
  528}
  529 
  530 
  533{
  535}
  536 
  537 
  540{
  542}
  543 
  544 
  547{
  548  char *rdir;
  549  unsigned int len;
  550  unsigned int pos;
  551  unsigned int pos2;
  553 
  555  if (rdir == NULL)
  556  {
  559  }
  560 
  561  len = strlen (rdir);
  562 
  563  pos = 1; 
  564 
  565  
  566  pos2 = len;
  568  while (pos <= pos2)
  569  {
  571    {
  572      rdir[pos2] = '\0';
  575      {
  577                    "Creating directory `%s' failed\n",
  578                    rdir);
  581      }
  584      {
  585        pos2++;
  586        break;
  587      }
  588    }
  589    pos2--;
  590  }
  591  rdir[len] = '\0';
  592  if (pos < pos2)
  593    pos = pos2;
  594  
  595  while (pos <= len)
  596  {
  598    {
  599      rdir[pos] = '\0';
  602      {
  604                    "Creating directory `%s' failed\n",
  605                    rdir);
  608      }
  610      {
  612                     S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH
  613                     | S_IXOTH);    
  614 
  615        if ((
ret != 0) && (errno != EEXIST))
 
  616        {
  620        }
  621      }
  623    }
  624    pos++;
  625  }
  628}
  629 
  630 
  633{
  634  char *rdir;
  635  size_t len;
  636  int eno;
  638 
  640  if (NULL == rdir)
  641  {
  642    errno = EINVAL;
  644  }
  645  if (0 == access (rdir, W_OK))
  646  {
  649  }
  650  len = strlen (rdir);
  652    len--;
  653  rdir[len] = '\0';
  654  
  655  if (0 == len)
  656  {
  659  }
  662       (0 != access (rdir, W_OK)) )
  664  eno = errno;
  666  errno = eno;
  668}
  669 
  670 
  671ssize_t
  674                       size_t len)
  675{
  677  {
  678    errno = EINVAL;
  680  }
  681  return read (
h->fd, 
result, len);
 
  682}
  683 
  684 
  685ssize_t
  688                     size_t len)
  689{
  692  int eno;
  693 
  697  if (NULL == fh)
  700  eno = errno;
  703  errno = eno;
  705}
  706 
  707 
  708ssize_t
  710                        const void *buffer,
  711                        size_t n)
  712{
  714  {
  715    errno = EINVAL;
  717  }
  719                buffer,
  720                n);
  721}
  722 
  723 
  724ssize_t
  726                                 const void *buffer,
  727                                 size_t n)
  728{
  729  int flags;
  731 
  733  {
  734    errno = EINVAL;
  736  }
  737  
  738  flags = fcntl (
h->fd, F_GETFL);
 
  739  if (0 != (flags & O_NONBLOCK))
  740    (void) fcntl (
h->fd, F_SETFL, flags - O_NONBLOCK);
 
  741  ret = write (
h->fd, buffer, n);
 
  742  if (0 == (flags & O_NONBLOCK))
  743    (void) fcntl (
h->fd, F_SETFL, flags);
 
  745}
  746 
  747 
  750                      const void *buf,
  751                      size_t buf_size,
  753{
  754  char *tmpl;
  756 
  759  {
  761                              "mkstemp",
  762                              fn);
  764  }
  765  {
  766    char *dname;
  767 
  770                     "%s/XXXXXX",
  771                     dirname (dname));
  773  }
  776  {
  778                              "mkstemp",
  779                              tmpl);
  782  }
  783 
  786  {
  788                              "chmod",
  789                              tmpl);
  791    if (0 != unlink (tmpl))
  793                                "unlink",
  794                                tmpl);
  797  }
  798  if (buf_size !=
  800             buf,
  801             buf_size))
  802  {
  804                              "write",
  805                              tmpl);
  807    if (0 != unlink (tmpl))
  809                                "unlink",
  810                                tmpl);
  813  }
  815 
  816  if (0 != link (tmpl,
  817                 fn))
  818  {
  819    if (0 != unlink (tmpl))
  821                                "unlink",
  822                                tmpl);
  825  }
  826  if (0 != unlink (tmpl))
  828                              "unlink",
  829                              tmpl);
  832 
  833 
  834}
  835 
  836 
  837int
  840                            void *callback_cls)
  841{
  842  DIR *dinfo;
  843  struct dirent *finfo;
  844  int count = 0;
  847  char *dname;
  848  unsigned int name_len;
  849  unsigned int n_size;
  850 
  853  if (NULL == dname)
  855  while ( (strlen (dname) > 0) &&
  857    dname[strlen (dname) - 1] = '\0';
  858  dinfo = opendir (dname);
  859  if (NULL == dinfo)
  860  {
  862                       "opendir",
  863                       dname);
  866  }
  867  name_len = 256;
  870  while (NULL != (finfo = readdir (dinfo)))
  871  {
  872    if ((0 == strcmp (finfo->d_name, ".")) ||
  873        (0 == strcmp (finfo->d_name, "..")))
  874      continue;
  875    if (NULL != callback)
  876    {
  877      if (name_len < strlen (finfo->d_name))
  878      {
  880        name_len = strlen (finfo->d_name);
  883      }
  884      
  885
  886
  888                       n_size,
  889                       "%s%s%s",
  890                       dname,
  891                       (0 == strcmp (dname,
  893                       ? ""
  895                       finfo->d_name);
  896      ret = callback (callback_cls,
 
  899      {
  900        closedir (dinfo);
  904          return count;
  906      }
  907    }
  908    count++;
  909  }
  910  closedir (dinfo);
  913  return count;
  914}
  915 
  916 
  926static bool
  928{
  929  
  930  const char *str_pos = 
str;
 
  931  
  932  const char *pat_pos = pattern;
  933  
  934  const char *str_bt = NULL;
  935  
  936  const char *pat_bt = NULL;
  937 
  938  for (;;)
  939  {
  940    if (*pat_pos == '*')
  941    {
  942      str_bt = str_pos;
  943      pat_bt = pat_pos++;
  944    }
  945    else if (*pat_pos == *str_pos)
  946    {
  947      if ('\0' == *pat_pos)
  948        return true;
  949      str_pos++;
  950      pat_pos++;
  951    }
  952    else
  953    {
  954      if (NULL == str_bt)
  955        return false;
  956      
  957
  958      str_pos = str_bt + 1;
  959      if ('\0' == *str_pos)
  960        return false;
  961      pat_pos = pat_bt;
  962    }
  963  }
  964}
  965 
  966 
  968{
  972 
  977};
  978 
  991{
  993  const char *fn;
  994 
  996  fn = (NULL == fn) ? 
filename : (fn + 1);
 
  997 
  999       "checking glob '%s' against '%s'\n",
 1001       fn);
 1002 
 1004  {
 1006 
 1008         "found glob match '%s'\n",
 1013      return cbret;
 1014  }
 1016}
 1017 
 1018 
 1019int
 1022                  void *callback_cls)
 1023{
 1025  char *sep;
 1027 
 1028  if ( (NULL != strrchr (glob_pattern, '+')) ||
 1029       (NULL != strrchr (glob_pattern, '[')) ||
 1030       (NULL != strrchr (glob_pattern, '~')) )
 1031  {
 1033         "unsupported glob pattern: '%s'\n",
 1034         glob_pattern);
 1036    return -1;
 1037  }
 1038 
 1040  if (NULL == sep)
 1041  {
 1043    return -1;
 1044  }
 1045 
 1046  *sep = '\0';
 1047 
 1048  if (NULL != strchr (mypat, '*'))
 1049  {
 1053         "glob pattern may only contain '*' in the final path component\n");
 1054    return -1;
 1055  }
 1056 
 1057  {
 1060      .cb = callback,
 1061      .cls = callback_cls,
 1062      .nres = 0,
 1063    };
 1065         "scanning directory '%s' for glob matches on '%s'\n",
 1066         mypat,
 1070                                      &gc
 1071                                      );
 1074  }
 1075}
 1076 
 1077 
 1088               const char *fn)
 1089{
 1090  (void) unused;
 1093}
 1094 
 1095 
 1098{
 1099  struct stat istat;
 1100 
 1102  {
 1105  }
 1109                S_IWUSR | S_IRUSR | S_IXUSR);
 1112  if ( (errno != EISDIR) &&
 1113       
 1114
 1115
 1119  {
 1121                       "rmdir",
 1124  }
 1128                                  NULL))
 1131  {
 1133                       "rmdir",
 1136  }
 1138}
 1139 
 1140 
 1143                       const char *dst)
 1144{
 1145  char *buf;
 1146  uint64_t pos;
 1148  size_t len;
 1149  ssize_t sret;
 1152 
 1154  {
 1157  }
 1158  pos = 0;
 1159  in =
 1161  if (! in)
 1162  {
 1165  }
 1166  out =
 1174  if (! out)
 1175  {
 1179  }
 1182  {
 1184    if (len > 
size - pos)
 
 1187    if ((sret < 0) || (len != (size_t) sret))
 1190    if ((sret < 0) || (len != (size_t) sret))
 1192    pos += len;
 1193  }
 1207}
 1208 
 1209 
 1210void
 1212{
 1213  char *idx;
 1214  char c;
 1215 
 1216  for (idx = fn; *idx; idx++)
 1217  {
 1218    c = *idx;
 1219 
 1220    if ((c == '/') || (c == '\\') || (c == ':') || (c == '*') || (c == '?') ||
 1221        (c ==
 1222         '"')
 1223        ||
 1224        (c == '<') || (c == '>') || (c == '|') )
 1225    {
 1226      *idx = '_';
 1227    }
 1228  }
 1229}
 1230 
 1231 
 1234                               const char *user)
 1235{
 1236  struct passwd *pws;
 1237 
 1238  pws = getpwnam (user);
 1239  if (NULL == pws)
 1240  {
 1242         _ (
"Cannot obtain information about user `%s': %s\n"),
 
 1243         user,
 1244         strerror (errno));
 1246  }
 1247  if (0 != chown (
filename, pws->pw_uid, pws->pw_gid))
 
 1248  {
 1251  }
 1253}
 1254 
 1255 
 1260{
 1261  char *expfn;
 1263 
 1264  int oflags;
 1267 
 1269  if (NULL == expfn)
 1270    return NULL;
 1271 
 1274    oflags = O_RDWR; 
 1276    oflags = O_RDONLY;
 1278    oflags = O_WRONLY;
 1279  else
 1280  {
 1283    return NULL;
 1284  }
 1286    oflags |= (O_CREAT | O_EXCL);
 1288    oflags |= O_TRUNC;
 1290    oflags |= O_APPEND;
 1292  {
 1294    {
 1296      oflags |= O_CREAT;
 1298    }
 1299  }
 1300 
 1301  
 1302  
 1303  
 1305             oflags
 1306#if O_CLOEXEC
 1307             | O_CLOEXEC
 1308#endif
 1312  {
 1315    else
 1318    return NULL;
 1319  }
 1320 
 1322 
 1324 
 1327}
 1328 
 1329 
 1332{
 1334 
 1336  {
 1337    errno = EINVAL;
 1339  }
 1340 
 1342  if (0 != close (
h->fd))
 
 1343  {
 1346  }
 1349}
 1350 
 1351 
 1354{
 1356 
 1357  if ((((off_t) -1) == lseek (fno, 0, SEEK_CUR)) && (EBADF == errno))
 1358    return NULL; 
 1359 
 1361 
 1363 
 1364  return fh;
 1365}
 1366 
 1367 
 1370{
 1371  int fno;
 1372 
 1374  if (-1 == fno)
 1375    return NULL;
 1377}
 1378 
 1379 
 1384{
 1389 
 1394};
 1395 
 1396 
 1397#ifndef MAP_FAILED
 1398#define MAP_FAILED ((void *) -1)
 1399#endif
 1400 
 1401 
 1402void *
 1406                      size_t len)
 1407{
 1408  int prot;
 1409 
 1411  {
 1412    errno = EINVAL;
 1413    return NULL;
 1414  }
 1415  prot = 0;
 1417    prot = PROT_READ;
 1419    prot |= PROT_WRITE;
 1421  (*m)->addr = mmap (NULL, len, prot, MAP_SHARED, 
h->fd, 0);
 
 1424  {
 1426    return NULL;
 1427  }
 1428  (*m)->len = len;
 1429  return (*m)->addr;
 1430}
 1431 
 1432 
 1435{
 1437 
 1439  {
 1440    errno = EINVAL;
 1442  }
 1446}
 1447 
 1448 
 1451{
 1453  {
 1454    errno = EINVAL;
 1456  }
 1457 
 1458#if ! defined(__linux__) || ! defined(GNU)
 1460#else
 1462#endif
 1463}
 1464 
 1465 
 1468{
 1470 
 1471#if HAVE_PIPE2 && O_CLOEXEC
 1472  if (-1 == pipe2 (
fd, O_CLOEXEC))
 
 1473#else
 1474  if (-1 == pipe (
fd))
 
 1475#endif
 1476  {
 1477    int eno = errno;
 1478 
 1480    errno = eno;
 1481    return NULL;
 1482  }
 1484}
 1485 
 1486 
 1490{
 1493  int flags;
 1494  int eno = 0; 
 1495 
 1498  {
 1500    p->fd[0]->fd = 
fd[0];
 
 1502    {
 1503      flags = fcntl (
fd[0], F_GETFL);
 
 1504      flags |= O_NONBLOCK;
 1505      if (0 > fcntl (
fd[0], F_SETFL, flags))
 
 1506      {
 1508        eno = errno;
 1509      }
 1510    }
 1511    flags = fcntl (
fd[0], F_GETFD);
 
 1512    flags |= FD_CLOEXEC;
 1513    if (0 > fcntl (
fd[0], F_SETFD, flags))
 
 1514    {
 1516      eno = errno;
 1517    }
 1518  }
 1519 
 1521  {
 1523    p->fd[1]->fd = 
fd[1];
 
 1525    {
 1526      flags = fcntl (
fd[1], F_GETFL);
 
 1527      flags |= O_NONBLOCK;
 1528      if (0 > fcntl (
fd[1], F_SETFL, flags))
 
 1529      {
 1531        eno = errno;
 1532      }
 1533    }
 1534    flags = fcntl (
fd[1], F_GETFD);
 
 1535    flags |= FD_CLOEXEC;
 1536    if (0 > fcntl (
fd[1], F_SETFD, flags))
 
 1537    {
 1539      eno = errno;
 1540    }
 1541  }
 1543  {
 1544    errno = eno;
 1546    if (
p->fd[0]->fd >= 0)
 
 1548    if (
p->fd[1]->fd >= 0)
 
 1553    errno = eno;
 1554    return NULL;
 1555  }
 1557}
 1558 
 1559 
 1563{
 1565 
 1567  {
 1569    {
 1572    }
 1573  }
 1575  {
 1577    {
 1580    }
 1581  }
 1583}
 1584 
 1585 
 1589{
 1591 
 1593  {
 1595    {
 1598    }
 1599  }
 1601  {
 1603    {
 1606    }
 1607  }
 1608 
 1610}
 1611 
 1612 
 1615{
 1619  int read_end_close_errno;
 1620  int write_end_close_errno;
 1621 
 1623  read_end_close_errno = errno;
 1625  write_end_close_errno = errno;
 1627 
 1629  {
 1630    errno = read_end_close_errno;
 1631    ret = read_end_close;
 
 1632  }
 1634  {
 1635    errno = write_end_close_errno;
 1636    ret = write_end_close;
 
 1637  }
 1638 
 1640}
 1641 
 1642 
 1646{
 1647  switch (n)
 1648  {
 1652 
 1653  default:
 1655    return NULL;
 1656  }
 1657}
 1658 
 1659 
 1662                                   int *dst)
 1663{
 1664  if (NULL == fh)
 1668}
 1669 
 1670 
 1681{
 1682  const char *option = cls;
 1683  char *tmpname;
 1684 
 1687                                               "PATHS",
 1688                                               option,
 1689                                               &tmpname))
 1690  {
 1692                               "PATHS",
 1693                               option);
 1695  }
 1698  {
 1700                              "remove",
 1701                              tmpname);
 1704  }
 1707}
 1708 
 1709 
 1710void
 1713                           const char *option)
 1714{
 1719                                                    (void *) option));
 1720}
 1721 
 1722 
 1723
static enum GNUNET_GenericReturnValue get_size_rec(void *cls, const char *fn)
Iterate over all files in the given directory and accumulate their size.
 
#define COPY_BLK_SIZE
Block size for IO for copying files.
 
static enum GNUNET_GenericReturnValue glob_cb(void *cls, const char *filename)
Function called with a filename.
 
#define LOG_STRERROR_FILE(kind, syscall, filename)
 
static int translate_unix_perms(enum GNUNET_DISK_AccessPermissions perm)
Translate GNUnet-internal permission bitmap to UNIX file access permission bitmap.
 
static enum GNUNET_GenericReturnValue file_test_internal(const char *fil, int amode)
Check if fil can be accessed using amode.
 
static bool glob_match(const char *pattern, const char *str)
Check for a simple wildcard match.
 
static enum GNUNET_GenericReturnValue purge_cfg_dir(void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg)
Helper function for GNUNET_DISK_purge_cfg_dir.
 
static char * mktemp_name(const char *t)
Create the name for a temporary file or directory from a template.
 
#define LOG_STRERROR(kind, syscall)
 
static enum GNUNET_GenericReturnValue remove_helper(void *unused, const char *fn)
Function that removes the given directory by calling GNUNET_DISK_directory_remove().
 
enum GNUNET_GenericReturnValue GNUNET_DISK_internal_file_handle_(const struct GNUNET_DISK_FileHandle *fh, int *dst)
Retrieve OS file handle.
 
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
 
static struct GNUNET_ARM_Handle * h
Connection with ARM.
 
static int ret
Final status code.
 
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
 
static char * dir
Set to the directory where runtime files are stored.
 
static int end
Set if we are to shutdown all services (including ARM).
 
static const char * dir_name
Top-level directory we monitor to auto-publish.
 
static char * cfg_filename
Name of the configuration file.
 
static char * name
Name (label) of the records to list.
 
static struct GNUNET_SCHEDULER_Task * t
Main task.
 
static char * res
Currently read line or NULL on EOF.
 
static int result
Global testing status.
 
static struct GNUNET_OS_Process * p
Helper process we started.
 
static enum @49 mode
Should we do a PUT (mode = 0) or GET (mode = 1);.
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_filename(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be the name of a file or directory.
 
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_parse_and_run(const struct GNUNET_OS_ProjectData *pd, const char *filename, GNUNET_CONFIGURATION_Callback cb, void *cb_cls)
Parse a configuration file filename and run the function cb with the resulting configuration object.
 
const struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_handle(const struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd n)
Get the handle to a particular pipe end.
 
struct GNUNET_DISK_FileHandle * GNUNET_DISK_file_open(const char *fn, enum GNUNET_DISK_OpenFlags flags, enum GNUNET_DISK_AccessPermissions perm)
Open a file.
 
void GNUNET_DISK_filename_canonicalize(char *fn)
Removes special characters as ':' from a filename.
 
int GNUNET_DISK_glob(const char *glob_pattern, GNUNET_FileNameCallback callback, void *callback_cls)
Find all files matching a glob pattern.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_change_owner(const char *filename, const char *user)
Change owner of a file.
 
char * GNUNET_DISK_mktemp(const char *t)
Create an (empty) temporary file on disk.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory).
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_get_identifiers(const char *filename, uint64_t *dev, uint64_t *ino)
Obtain some unique identifiers for the given file that can be used to identify it in the local system...
 
char * GNUNET_DISK_file_backup(const char *fil)
Move a file out of the way (create a backup) by renaming it to "orig.NUM~" where NUM is the smallest ...
 
void GNUNET_DISK_fix_permissions(const char *fn, int require_uid_match, int require_gid_match)
Update POSIX permissions mask of a file on disk.
 
struct GNUNET_DISK_FileHandle * GNUNET_DISK_pipe_detach_end(struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd end)
Detaches one of the ends from the pipe.
 
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe_from_fd(enum GNUNET_DISK_PipeFlags pf, int fd[2])
Creates a pipe object from a couple of file descriptors.
 
GNUNET_DISK_OpenFlags
Specifies how a file should be opened.
 
ssize_t GNUNET_DISK_file_write(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file.
 
GNUNET_DISK_PipeFlags
Flags for GNUNET_DISK_pipe().
 
off_t GNUNET_DISK_file_seek(const struct GNUNET_DISK_FileHandle *h, off_t offset, enum GNUNET_DISK_Seek whence)
Move the read/write pointer in a file.
 
struct GNUNET_DISK_PipeHandle * GNUNET_DISK_pipe(enum GNUNET_DISK_PipeFlags pf)
Creates an interprocess channel.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_test_read(const char *fil)
Check that fil corresponds to a filename and the file has read permissions.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_size(const char *filename, uint64_t *size, int include_symbolic_links, int single_file_mode)
Get the size of the file (or directory) of the given file (in bytes).
 
GNUNET_DISK_AccessPermissions
File access permissions, UNIX-style.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close(struct GNUNET_DISK_PipeHandle *p)
Closes an interprocess channel.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_fn_write(const char *fn, const void *buf, size_t buf_size, enum GNUNET_DISK_AccessPermissions mode)
Write a buffer to a file atomically.
 
char * GNUNET_DISK_mkdtemp(const char *t)
Create an (empty) temporary directory on disk.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_copy(const char *src, const char *dst)
Copy a file.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_remove(const char *filename)
Remove all files in a directory (rm -rf).
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_sync(const struct GNUNET_DISK_FileHandle *h)
Write file changes to disk.
 
GNUNET_DISK_Seek
Constants for specifying how to seek.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_handle_invalid(const struct GNUNET_DISK_FileHandle *h)
Checks whether a handle is invalid.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_close(struct GNUNET_DISK_FileHandle *h)
Close an open file.
 
void GNUNET_DISK_purge_cfg_dir(const struct GNUNET_OS_ProjectData *pd, const char *cfg_filename, const char *option)
Remove the directory given under option in section [PATHS] in configuration under cfg_filename.
 
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_native(FILE *fd)
Get a handle from a native FD.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
 
void * GNUNET_DISK_file_map(const struct GNUNET_DISK_FileHandle *h, struct GNUNET_DISK_MapHandle **m, enum GNUNET_DISK_MapType access, size_t len)
Map a file into memory.
 
struct GNUNET_DISK_FileHandle * GNUNET_DISK_get_handle_from_int_fd(int fno)
Get a handle from a native integer FD.
 
ssize_t GNUNET_DISK_file_read(const struct GNUNET_DISK_FileHandle *h, void *result, size_t len)
Read the contents of a binary file into a buffer.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_handle_size(struct GNUNET_DISK_FileHandle *fh, off_t *size)
Get the size of an open file.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_pipe_close_end(struct GNUNET_DISK_PipeHandle *p, enum GNUNET_DISK_PipeEnd end)
Closes one half of an interprocess channel.
 
ssize_t GNUNET_DISK_file_write_blocking(const struct GNUNET_DISK_FileHandle *h, const void *buffer, size_t n)
Write a buffer to a file, blocking, if necessary.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_file_unmap(struct GNUNET_DISK_MapHandle *h)
Unmap a file.
 
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create(const char *dir)
Implementation of "mkdir -p".
 
GNUNET_DISK_PipeEnd
Enumeration identifying the two ends of a pipe.
 
ssize_t GNUNET_DISK_fn_read(const char *fn, void *result, size_t len)
Read the contents of a binary file into a buffer.
 
GNUNET_DISK_MapType
Specifies what type of memory map is desired.
 
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
 
@ GNUNET_DISK_OPEN_READ
Open the file for reading.
 
@ GNUNET_DISK_OPEN_FAILIFEXISTS
Fail if file already exists.
 
@ GNUNET_DISK_OPEN_WRITE
Open the file for writing.
 
@ GNUNET_DISK_OPEN_TRUNCATE
Truncate file if it exists.
 
@ GNUNET_DISK_OPEN_CREATE
Create file if it doesn't exist.
 
@ GNUNET_DISK_OPEN_APPEND
Append to the file.
 
@ GNUNET_DISK_OPEN_READWRITE
Open the file for both reading and writing.
 
@ GNUNET_DISK_PF_BLOCKING_WRITE
Configure write end to block when writing if set.
 
@ GNUNET_DISK_PF_BLOCKING_READ
Configure read end to block when reading if set.
 
@ GNUNET_DISK_PERM_OTHER_EXEC
Everybody can execute.
 
@ GNUNET_DISK_PERM_USER_EXEC
Owner can execute.
 
@ GNUNET_DISK_PERM_USER_READ
Owner can read.
 
@ GNUNET_DISK_PERM_NONE
Nobody is allowed to do anything to the file.
 
@ GNUNET_DISK_PERM_GROUP_READ
Group can read.
 
@ GNUNET_DISK_PERM_GROUP_EXEC
Group can execute.
 
@ GNUNET_DISK_PERM_GROUP_WRITE
Group can write.
 
@ GNUNET_DISK_PERM_USER_WRITE
Owner can write.
 
@ GNUNET_DISK_PERM_OTHER_READ
Everybody can read.
 
@ GNUNET_DISK_PERM_OTHER_WRITE
Everybody can write.
 
@ GNUNET_DISK_PIPE_END_WRITE
The writing-end of a pipe.
 
@ GNUNET_DISK_PIPE_END_READ
The reading-end of a pipe.
 
@ GNUNET_DISK_MAP_TYPE_WRITE
Write-able memory map.
 
@ GNUNET_DISK_MAP_TYPE_READ
Read-only memory map.
 
enum GNUNET_GenericReturnValue(* GNUNET_FileNameCallback)(void *cls, const char *filename)
Function called with a filename.
 
#define GNUNET_log(kind,...)
 
GNUNET_GenericReturnValue
Named constants for return values.
 
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
 
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
 
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
 
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
 
@ GNUNET_ERROR_TYPE_WARNING
 
@ GNUNET_ERROR_TYPE_ERROR
 
@ GNUNET_ERROR_TYPE_DEBUG
 
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
 
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
 
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
 
#define GNUNET_new(type)
Allocate a struct or union of the given type.
 
#define GNUNET_malloc(size)
Wrapper around malloc.
 
#define GNUNET_free(ptr)
Wrapper around free.
 
char * GNUNET_STRINGS_filename_expand(const char *fil)
Complete filename (a la shell) from abbrevition.
 
static unsigned int size
Size of the "table".
 
Handle used to access files (and pipes).
 
int fd
File handle on Unix-like systems.
 
Handle for a memory-mapping operation.
 
void * addr
Address where the map is in memory.
 
size_t len
Number of bytes mapped.
 
Handle used to manage a pipe.
 
struct GNUNET_DISK_FileHandle * fd[2]
File descriptors for the pipe.
 
Project-specific data used to help the OS subsystem find installation paths.
 
Closure for the recursion to determine the file size of a directory.
 
uint64_t total
Set to the total file size.
 
int include_sym_links
GNUNET_YES if symbolic links should be included.
 
int single_file_mode
GNUNET_YES if mode is file-only (return total == -1 for directories).
 
GNUNET_FileNameCallback cb
 
int nres
Number of files that actually matched the glob pattern.