#include <atalk/cnid.h>
#endif /* CNID_DB*/
-/* Global: eg volume.c needs em */
-
-const vol_opt_name_t vol_opt_names[] = {
+static const vol_opt_name_t vol_opt_names[] = {
{AFPVOL_A2VOL, "PRODOS"}, /* prodos volume */
{AFPVOL_CRLF, "CRLF"}, /* cr/lf translation */
{AFPVOL_NOADOUBLE, "NOADOUBLE"}, /* don't create .AppleDouble by default */
{0, NULL}
};
-const vol_opt_name_t vol_opt_casefold[] = {
+static const vol_opt_name_t vol_opt_casefold[] = {
{AFPVOL_MTOUUPPER, "MTOULOWER"},
{AFPVOL_MTOULOWER, "MTOULOWER"},
{AFPVOL_UTOMUPPER, "UTOMUPPER"},
#define CNID_DBPATH 6
#define VOLUME_OPTS 7
#define VOLCASEFOLD 8
+#define EXTATTRTYPE 9
static const info_option_t info_options[] = {
{"MAC_CHARSET", MAC_CHARSET},
{"CNID_DBPATH", CNID_DBPATH},
{"VOLUME_OPTS", VOLUME_OPTS},
{"VOLCASEFOLD", VOLCASEFOLD},
- {NULL, 0}
+ {"EXTATTRTYPE", EXTATTRTYPE},
+ {NULL, 0}
};
static char* find_in_path( char *path, char *subdir, size_t maxlen)
char abspath[MAXPATHLEN];
char *p;
- if (stat(path, &st) != 0) {
- return NULL;
- }
+ strlcpy(abspath, path, sizeof(abspath));
- strlcpy (abspath, path, sizeof(abspath));
+ /* we might be called from `ad cp ...` with non existing target */
+ if (stat(abspath, &st) != 0) {
+ if (errno != ENOENT)
+ return NULL;
- if (!S_ISDIR(st.st_mode)) {
- if (NULL == (p=strrchr(abspath, '/')) )
+ if (NULL == (p = strrchr(abspath, '/')) )
+ /* single component `ad cp SOURCEFILE TARGETFILE`, use "." instead */
strcpy(abspath, ".");
else
+ /* try without the last path element */
+ *p = '\0';
+
+ if (stat(abspath, &st) != 0) {
+ return NULL;
+ }
+ }
+
+ if (S_ISREG(st.st_mode)) {
+ /* single file copy SOURCE */
+ if (NULL == (p = strrchr(abspath, '/')) )
+ /* no path, use "." instead */
+ strcpy(abspath, ".");
+ else
+ /* try without the last path element */
*p = '\0';
}
}
break;
case CNIDDBDPORT:
- vol->v_dbd_port = atoi(value);
+ if ((vol->v_dbd_port = strdup(value)) == NULL) {
+ fprintf (stderr, "strdup: %s", strerror(errno));
+ return -1;
+ }
break;
case CNID_DBPATH:
if ((vol->v_dbpath = strdup(value)) == NULL) {
}
break;
case ADOUBLE_VER:
- if (strcasecmp(value, "v1") == 0) {
- vol->v_adouble = AD_VERSION1;
- vol->ad_path = ad_path;
- }
-#if AD_VERSION == AD_VERSION2
- else if (strcasecmp(value, "v2") == 0) {
+ if (strcasecmp(value, "v2") == 0) {
vol->ad_path = ad_path;
vol->v_adouble = AD_VERSION2;
- }
- else if (strcasecmp(value, "osx") == 0) {
- vol->v_adouble = AD_VERSION2_OSX;
- vol->ad_path = ad_path_osx;
- }
-#endif
- else {
+ } else if (strcasecmp(value, "ea") == 0) {
+ vol->ad_path = ad_path_ea;
+ vol->v_adouble = AD_VERSION_EA;
+ } else {
+
fprintf (stderr, "unknown adouble version: %s, %s", buf, value);
return -1;
}
case VOLCASEFOLD:
parse_options(value, &vol->v_casefold, &vol_opt_casefold[0]);
break;
+ case EXTATTRTYPE:
+ if (strcasecmp(value, "AFPVOL_EA_AD") == 0)
+ vol->v_vfs_ea = AFPVOL_EA_AD;
+ else if (strcasecmp(value, "AFPVOL_EA_SYS") == 0)
+ vol->v_vfs_ea = AFPVOL_EA_SYS;
+ break;
default:
fprintf (stderr, "unknown volume information: %s, %s", buf, value);
return (-1);
strlcat(buf, item, sizeof(buf));
switch (vol->v_adouble) {
- case AD_VERSION1:
- strlcat(buf, "ADOUBLE_VER:v1\n", sizeof(buf));
- break;
case AD_VERSION2:
strlcat(buf, "ADOUBLE_VER:v2\n", sizeof(buf));
break;
- case AD_VERSION2_OSX:
- strlcat(buf, "ADOUBLE_VER:osx\n", sizeof(buf));
- break;
- case AD_VERSION1_SFM:
- strlcat(buf, "ADOUBLE_VER:sfm\n", sizeof(buf));
+ case AD_VERSION_EA:
+ strlcat(buf, "ADOUBLE_VER:ea\n", sizeof(buf));
break;
}
strlcat(item, "\n", sizeof(item));
strlcat(buf, item, sizeof(buf));
- if (strlen(buf) >= sizeof(buf)-1)
- LOG(log_debug, logtype_afpd,"Error writing .volinfo file: buffer too small, %s", buf);
+ /* ExtendedAttributes */
+ strcpy(item, "EXTATTRTYPE:");
+ switch (vol->v_vfs_ea) {
+ case AFPVOL_EA_SYS:
+ strlcat(item, "AFPVOL_EA_SYS\n", sizeof(item));
+ break;
+ case AFPVOL_EA_AD:
+ strlcat(item, "AFPVOL_EA_AD\n", sizeof(item));
+ break;
+ case AFPVOL_EA_NONE:
+ strlcat(item, "AFPVOL_EA_NONE\n", sizeof(item));
+ break;
+ default:
+ strlcat(item, "AFPVOL_EA_UNKNOWN\n", sizeof(item));
+ }
+ strlcat(buf, item, sizeof(buf));
+ if (strlen(buf) >= sizeof(buf)-1)
+ LOG(log_debug, logtype_afpd,"Error writing .volinfo file: buffer too small, %s", buf);
if (write( fd, buf, strlen(buf)) < 0 || ftruncate(fd, strlen(buf)) < 0 ) {
LOG(log_debug, logtype_afpd,"Error writing .volinfo file: %s", strerror(errno));
}