• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/ap/gpl/timemachine/netatalk-2.2.5/etc/afpd/

Lines Matching refs:volume

63 #include "volume.h"
82 struct vol *current_vol; /* last volume from getvolbyvid() */
96 #define VOLOPT_PASSWORD 4 /* volume password */
100 #define VOLOPT_LIMITSIZE 8 /* Limit the size of the volume */
191 * $d -> volume pathname on server
198 * $v -> volume name or basename if null
409 /* we'll assume it's a volume name. */
532 LOG(log_debug, logtype_afpd, "CNID Server for volume '%s': %s:%s",
551 /* this code allows forced uid/gid per volume settings */
589 LOG(log_debug, logtype_afpd, "ignoring unknown volume option: %s", tmp);
597 struct vol *volume;
598 for ( volume = Volumes; volume; volume = volume->v_next ) {
599 if (volume->v_hide && !strcasecmp_w( volume->v_name, name ) ) {
600 volume->v_hide = 0;
610 const int user /* user defined volume */
613 struct vol *volume;
704 for ( volume = Volumes; volume; volume = volume->v_next ) {
705 if ((utf8_encoding() && (strcasecmp_w(volume->v_u8mname, u8mtmpname) == 0))
707 (!utf8_encoding() && (strcasecmp_w(volume->v_macname, mactmpname) == 0))) {
708 if (volume->v_deleted) {
709 volume->v_new = hide = 1;
712 "Duplicate volume name, check AppleVolumes files: previous: \"%s\", new: \"%s\"",
713 volume->v_localname, name);
719 if (!( volume = (struct vol *)calloc(1, sizeof( struct vol ))) ) {
723 if ( NULL == ( volume->v_localname = strdup(name))) {
725 free(volume);
729 if ( NULL == ( volume->v_u8mname = strdup_w(u8mtmpname))) {
731 volume_free(volume);
732 free(volume);
735 if ( NULL == ( volume->v_macname = strdup_w(mactmpname))) {
737 volume_free(volume);
738 free(volume);
741 if (!( volume->v_path = (char *)malloc( strlen( path ) + 1 )) ) {
743 volume_free(volume);
744 free(volume);
748 volume->v_name = utf8_encoding()?volume->v_u8mname:volume->v_macname;
749 volume->v_hide = hide;
750 strcpy( volume->v_path, path );
753 volume->v_qfd = -1;
756 volume->v_vid = ++lastvid;
757 volume->v_vid = htons(volume->v_vid);
759 if (!check_vol_acl_support(volume)) {
760 LOG(log_debug, logtype_afpd, "creatvol(\"%s\"): disabling ACL support", volume->v_path);
767 volume->v_casefold = options[VOLOPT_CASEFOLD].i_value;
768 volume->v_flags |= options[VOLOPT_FLAGS].i_value;
771 volume->v_vfs_ea = options[VOLOPT_EA_VFS].i_value;
773 volume->v_ad_options = 0;
774 if ((volume->v_flags & AFPVOL_NODEV))
775 volume->v_ad_options |= ADVOL_NODEV;
776 if ((volume->v_flags & AFPVOL_CACHE))
777 volume->v_ad_options |= ADVOL_CACHE;
778 if ((volume->v_flags & AFPVOL_UNIX_PRIV))
779 volume->v_ad_options |= ADVOL_UNIXPRIV;
780 if ((volume->v_flags & AFPVOL_INV_DOTS))
781 volume->v_ad_options |= ADVOL_INVDOTS;
782 if ((volume->v_flags & AFPVOL_NOADOUBLE))
783 volume->v_ad_options |= ADVOL_NOADOUBLE;
784 if ((volume->v_flags & AFPVOL_FOLLOWSYM))
785 volume->v_ad_options |= ADVOL_FOLLO_SYML;
788 volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value);
791 volume->v_veto = strdup(options[VOLOPT_VETO].c_value);
794 volume->v_volcodepage = strdup(options[VOLOPT_ENCODING].c_value);
797 volume->v_maccodepage = strdup(options[VOLOPT_MACCHARSET].c_value);
800 volume->v_dbpath = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_DBPATH].c_value, pwd, path, name);
803 volume->v_cnidscheme = strdup(options[VOLOPT_CNIDSCHEME].c_value);
806 volume->v_cnidserver = strdup(options[VOLOPT_CNIDSERVER].c_value);
809 volume->v_cnidport = strdup(options[VOLOPT_CNIDPORT].c_value);
812 volume->v_umask = (mode_t)options[VOLOPT_UMASK].i_value;
815 volume->v_dperm = (mode_t)options[VOLOPT_DPERM].i_value;
818 volume->v_fperm = (mode_t)options[VOLOPT_FPERM].i_value;
821 volume->v_perm = (mode_t)options[VOLOPT_DFLTPERM].i_value;
824 volume->v_adouble = options[VOLOPT_ADOUBLE].i_value;
826 volume->v_adouble = AD_VERSION;
829 volume->v_limitsize = options[VOLOPT_LIMITSIZE].i_value;
832 volume->v_mtou_flags = 0;
833 if (!(volume->v_flags & AFPVOL_NOHEX))
834 volume->v_mtou_flags |= CONV_ESCAPEHEX;
835 if (!(volume->v_flags & AFPVOL_USEDOTS))
836 volume->v_mtou_flags |= CONV_ESCAPEDOTS;
837 if ((volume->v_flags & AFPVOL_EILSEQ))
838 volume->v_mtou_flags |= CONV__EILSEQ;
840 if ((volume->v_casefold & AFPVOL_MTOUUPPER))
841 volume->v_mtou_flags |= CONV_TOUPPER;
842 else if ((volume->v_casefold & AFPVOL_MTOULOWER))
843 volume->v_mtou_flags |= CONV_TOLOWER;
846 volume->v_utom_flags = CONV_IGNORE | CONV_UNESCAPEHEX;
847 if ((volume->v_casefold & AFPVOL_UTOMUPPER))
848 volume->v_utom_flags |= CONV_TOUPPER;
849 else if ((volume->v_casefold & AFPVOL_UTOMLOWER))
850 volume->v_utom_flags |= CONV_TOLOWER;
852 if ((volume->v_flags & AFPVOL_EILSEQ))
853 volume->v_utom_flags |= CONV__EILSEQ;
857 volume->v_forceuid = strdup(options[VOLOPT_FORCEUID].c_value);
859 volume->v_forceuid = NULL; /* set as null so as to return 0 later on */
863 volume->v_forcegid = strdup(options[VOLOPT_FORCEGID].c_value);
865 volume->v_forcegid = NULL; /* set as null so as to return 0 later on */
870 volume->v_preexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_PREEXEC].c_value, pwd, path, name);
871 volume->v_preexec_close = options[VOLOPT_PREEXEC].i_value;
874 volume->v_postexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_POSTEXEC].c_value, pwd, path, name);
877 volume->v_root_preexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_ROOTPREEXEC].c_value, pwd, path, name);
878 volume->v_root_preexec_close = options[VOLOPT_ROOTPREEXEC].i_value;
881 volume->v_root_postexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_ROOTPOSTEXEC].c_value, pwd, path, name);
884 volume->v_dperm |= volume->v_perm;
885 volume->v_fperm |= volume->v_perm;
887 /* Check EA support on volume */
888 if (volume->v_vfs_ea == AFPVOL_EA_AUTO)
889 check_ea_sys_support(volume);
890 initvol_vfs(volume);
893 if ((parent_or_child == 0) && (volume->v_flags & AFPVOL_TM)) {
894 char *uuid = get_vol_uuid(obj, volume->v_localname);
897 volume->v_localname);
899 volume->v_uuid = uuid;
901 volume->v_localname, volume->v_uuid);
905 volume->v_next = Volumes;
906 Volumes = volume;
1038 LOG(log_info, logtype_afpd, "AFP access denied for client IP '%s' to volume '%s' by denied list",
1050 LOG(log_info, logtype_afpd, "AFP access denied for client IP '%s' to volume '%s', not in allowed list",
1171 * Read a volume configuration file and add the volumes contained within to
1172 * the global volume list. This gets called from the forked afpd childs.
1180 * <unix path> [<volume name>] [allow:<user>,<@group>,...] \
1223 /* try putting a read lock on the volume file twice, sleep 1 second if first attempt fails */
1229 LOG(log_error, logtype_afpd, "readvolfile: can't lock volume file \"%s\"", path);
1433 static void volume_unlink(struct vol *volume)
1437 if (volume == Volumes) {
1444 if (vol == volume) {
1516 * Calculate used size of a TimeMachine volume
1518 * This assumes that the volume is used only for TimeMachine.
1520 * 1) readdir(path of volume)
1526 * The result of the calculation is returned in "volume->v_tm_used".
1527 * "volume->v_appended" gets reset to 0.
1528 * "volume->v_tm_cachetime" is updated with the current time from time(NULL).
1530 * "volume->v_tm_used" is cached for TM_USED_CACHETIME seconds and updated by
1531 * "volume->v_appended". The latter is increased by X every time the client
1534 * @param vol (rw) volume to calculate
1679 * set volume creation date
1684 struct vol *volume;
1687 for ( volume = Volumes; volume; volume = volume->v_next ) {
1688 if (volume->v_vid == id) {
1689 vol = volume;
1691 else if ((time_t)(AD_DATE_FROM_UNIX(date)) == volume->v_ctime) {
1693 volume = Volumes; /* restart */
1921 /* save the volume device number */
2026 struct vol *volume;
2035 for ( vcnt = 0, volume = Volumes; volume; volume = volume->v_next ) {
2036 if (!(volume->v_flags & AFPVOL_NOSTAT)) {
2039 if ( stat( volume->v_path, &st ) < 0 ) {
2041 volume->v_path, strerror(errno) );
2047 accessmode(volume, volume->v_path, &ma, NULL, &st);
2052 if (volume->v_hide) {
2053 continue; /* config file changed but the volume was mounted */
2057 len = ucs2_to_charset_allocate(CH_UTF8_MAC, &namebuf, volume->v_u8mname);
2059 len = ucs2_to_charset_allocate(obj->options.maccharset, &namebuf, volume->v_macname);
2065 /* set password bit if there's a volume password */
2066 *data = (volume->v_password) ? AFPSRVR_PASSWD : 0;
2068 /* Apple 2 clients running ProDOS-8 expect one volume to have
2074 *data |= (volume->v_flags & AFPVOL_A2VOL) ? AFPSRVR_CONFIGINFO : 0;
2086 LOG(log_error, logtype_afpd, "afp_getsrvrparms(%s): gettimeofday: %s", volume->v_path, strerror(errno) );
2098 static int volume_codepage(AFPObj *obj, struct vol *volume)
2103 if (!volume->v_volcodepage)
2104 volume->v_volcodepage = strdup("UTF8");
2106 if ( (charset_t) -1 == ( volume->v_volcharset = add_charset(volume->v_volcodepage)) ) {
2107 LOG (log_error, logtype_afpd, "Setting codepage %s as volume codepage failed", volume->v_volcodepage);
2111 if ( NULL == (charset = find_charset_functions(volume->v_volcodepage)) || charset->flags & CHARSET_ICONV ) {
2112 LOG (log_warning, logtype_afpd, "WARNING: volume encoding %s is *not* supported by netatalk, expect problems !!!!", volume->v_volcodepage);
2115 if (!volume->v_maccodepage)
2116 volume->v_maccodepage = strdup(obj->options.maccodepage);
2118 if ( (charset_t) -1 == ( volume->v_maccharset = add_charset(volume->v_maccodepage)) ) {
2119 LOG (log_error, logtype_afpd, "Setting codepage %s as mac codepage failed", volume->v_maccodepage);
2123 if ( NULL == ( charset = find_charset_functions(volume->v_maccodepage)) || ! (charset->flags & CHARSET_CLIENT) ) {
2124 LOG (log_error, logtype_afpd, "Fatal error: mac charset %s not supported", volume->v_maccodepage);
2127 volume->v_kTextEncoding = htonl(charset->kTextEncoding);
2132 static int volume_openDB(struct vol *volume)
2136 if ((volume->v_flags & AFPVOL_NODEV)) {
2140 if (volume->v_cnidscheme == NULL) {
2141 volume->v_cnidscheme = strdup(DEFAULT_CNID_SCHEME);
2143 volume->v_path, volume->v_cnidscheme);
2147 volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
2148 volume->v_cnidport ? volume->v_cnidport : Cnid_port);
2154 if (strcmp(volume->v_cnidscheme, "last") == 0) {
2156 volume->v_cnidscheme = strdup("tdb");
2161 if (volume->v_flags & AFPVOL_CDROM) {
2163 if (strcmp(volume->v_cnidscheme, "tdb") != 0) {
2164 free(volume->v_cnidscheme);
2165 volume->v_cnidscheme = strdup("tdb");
2167 volume->v_path, volume->v_cnidscheme);
2172 volume->v_cdb = cnid_open(volume->v_path,
2173 volume->v_umask,
2174 volume->v_cnidscheme,
2176 volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
2177 volume->v_cnidport ? volume->v_cnidport : Cnid_port);
2179 if ( ! volume->v_cdb && ! (flags & CNID_FLAG_MEMORY)) {
2181 LOG(log_error, logtype_afpd, "Can't open volume \"%s\" CNID backend \"%s\" ",
2182 volume->v_path, volume->v_cnidscheme);
2183 LOG(log_error, logtype_afpd, "Reopen volume %s using in memory temporary CNID DB.",
2184 volume->v_path);
2185 printf("Reopen volume %s using in memory temporary CNID DB.",
2186 volume->v_path);
2188 volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, "tdb", flags, NULL, NULL);
2192 if (volume->v_cdb) {
2193 setmessage("Something wrong with the volume's CNID DB, using temporary CNID DB instead."
2197 volume->v_flags &= ~AFPVOL_CACHE;
2202 return (!volume->v_cdb)?-1:0;
2220 LOG(log_info, logtype_afpd, "read-only volume '%s', can't test for EA support, disabling EAs", vol->v_localname);
2238 LOG(log_warning, logtype_afpd, "volume \"%s\" does not support Extended Attributes, using ea:ad instead",
2261 struct vol *volume;
2303 for ( volume = Volumes; volume; volume = volume->v_next ) {
2304 if ( strcasecmp_w( (ucs2_t*) volname, volume->v_name ) == 0 ) {
2309 if ( volume == NULL ) {
2313 /* check for a volume password */
2314 if (volume->v_password && strncmp(ibuf, volume->v_password, VOLPASSLEN)) {
2318 if (( volume->v_flags & AFPVOL_OPEN ) ) {
2319 /* the volume is already open */
2321 set_uidgid ( volume );
2323 return stat_vol(bitmap, volume, rbuf, rbuflen);
2326 if (volume->v_root_preexec) {
2327 if ((ret = afprun(1, volume->v_root_preexec, NULL)) && volume->v_root_preexec_close) {
2328 LOG(log_error, logtype_afpd, "afp_openvol(%s): root preexec : %d", volume->v_path, ret );
2334 set_uidgid ( volume );
2337 if (volume->v_preexec) {
2338 if ((ret = afprun(0, volume->v_preexec, NULL)) && volume->v_preexec_close) {
2339 LOG(log_error, logtype_afpd, "afp_openvol(%s): preexec : %d", volume->v_path, ret );
2344 if ( stat( volume->v_path, &st ) < 0 ) {
2348 if ( chdir( volume->v_path ) < 0 ) {
2354 LOG(log_error, logtype_afpd, "afp_openvol(%s): volume pathlen too long", volume->v_path);
2358 /* Normalize volume path */
2360 if ((volume->v_path = realpath(path, NULL)) == NULL)
2363 if ((volume->v_path = malloc(MAXPATHLEN+1)) == NULL)
2365 if (realpath(path, volume->v_path) == NULL) {
2366 free(volume->v_path);
2371 if ((tmp = strdup(volume->v_path)) == NULL) {
2372 free(volume->v_path);
2375 free(volume->v_path);
2376 volume->v_path = tmp;
2379 if (volume_codepage(obj, volume) < 0) {
2384 /* initialize volume variables
2388 volume->max_filename = UTF8FILELEN_EARLY;
2391 volume->max_filename = MACFILELEN;
2394 volume->v_flags |= AFPVOL_OPEN;
2395 volume->v_cdb = NULL;
2398 len = convert_string_allocate(CH_UCS2, CH_UTF8_MAC, volume->v_u8mname, namelen, &vol_mname);
2400 len = convert_string_allocate(CH_UCS2, obj->options.maccharset, volume->v_macname, namelen, &vol_mname);
2414 volume,
2417 bfromcstr(volume->v_path),
2421 LOG(log_error, logtype_afpd, "afp_openvol(%s): malloc: %s", volume->v_path, strerror(errno) );
2426 volume->v_root = dir;
2429 if (volume_openDB(volume) < 0) {
2431 volume->v_path, volume->v_cnidscheme);
2436 ret = stat_vol(bitmap, volume, rbuf, rbuflen);
2439 handle_special_folders(volume);
2440 savevolinfo(volume,
2441 volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
2442 volume->v_cnidport ? volume->v_cnidport : Cnid_port);
2446 * If you mount a volume twice, the second time the trash appears on
2453 if ((volume->v_cdb->flags & CNID_FLAG_PERSISTENT)) {
2456 if (cnid_getstamp(volume->v_cdb, volume->v_stamp, sizeof(volume->v_stamp)) < 0) {
2459 volume->v_path);
2466 cname( volume, volume->v_root, &p );
2472 if (volume->v_root) {
2473 dir_free( volume->v_root );
2474 volume->v_root = NULL;
2477 volume->v_flags &= ~AFPVOL_OPEN;
2478 if (volume->v_cdb != NULL) {
2479 cnid_close(volume->v_cdb);
2480 volume->v_cdb = NULL;
2623 poll if a volume is changed by other processes.
2780 * this is only intended for folders in the volume root
2931 continue; /* another volume name */