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

Lines Matching refs:volume

62 #include "volume.h"
80 struct vol *current_vol; /* last volume from getvolbyvid() */
94 #define VOLOPT_PASSWORD 4 /* volume password */
98 #define VOLOPT_LIMITSIZE 8 /* Limit the size of the volume */
189 * $d -> volume pathname on server
196 * $v -> volume name or basename if null
402 /* we'll assume it's a volume name. */
520 LOG(log_debug, logtype_afpd, "CNID Server for volume '%s': %s:%s",
539 /* this code allows forced uid/gid per volume settings */
577 LOG(log_debug, logtype_afpd, "ignoring unknown volume option: %s", tmp);
585 struct vol *volume;
586 for ( volume = Volumes; volume; volume = volume->v_next ) {
587 if (volume->v_hide && !strcasecmp_w( volume->v_name, name ) ) {
588 volume->v_hide = 0;
598 const int user /* user defined volume */
601 struct vol *volume;
692 for ( volume = Volumes; volume; volume = volume->v_next ) {
693 if ((utf8_encoding() && (strcasecmp_w(volume->v_u8mname, u8mtmpname) == 0))
695 (!utf8_encoding() && (strcasecmp_w(volume->v_macname, mactmpname) == 0))) {
697 "Duplicate volume name, check AppleVolumes files: previous: \"%s\", new: \"%s\"",
698 volume->v_localname, name);
699 if (volume->v_deleted) {
700 volume->v_new = hide = 1;
708 if (!( volume = (struct vol *)calloc(1, sizeof( struct vol ))) ) {
712 if ( NULL == ( volume->v_localname = strdup(name))) {
714 free(volume);
718 if ( NULL == ( volume->v_u8mname = strdup_w(u8mtmpname))) {
720 volume_free(volume);
721 free(volume);
724 if ( NULL == ( volume->v_macname = strdup_w(mactmpname))) {
726 volume_free(volume);
727 free(volume);
730 if (!( volume->v_path = (char *)malloc( strlen( path ) + 1 )) ) {
732 volume_free(volume);
733 free(volume);
737 volume->v_name = utf8_encoding()?volume->v_u8mname:volume->v_macname;
738 volume->v_hide = hide;
739 strcpy( volume->v_path, path );
742 volume->v_qfd = -1;
745 volume->v_vid = ++lastvid;
746 volume->v_vid = htons(volume->v_vid);
748 if (check_vol_acl_support(volume))
749 volume->v_flags |= AFPVOL_ACLS
755 volume->v_casefold = options[VOLOPT_CASEFOLD].i_value;
756 volume->v_flags |= options[VOLOPT_FLAGS].i_value;
759 volume->v_vfs_ea = options[VOLOPT_EA_VFS].i_value;
761 volume->v_ad_options = 0;
762 if ((volume->v_flags & AFPVOL_NODEV))
763 volume->v_ad_options |= ADVOL_NODEV;
764 if ((volume->v_flags & AFPVOL_CACHE))
765 volume->v_ad_options |= ADVOL_CACHE;
766 if ((volume->v_flags & AFPVOL_UNIX_PRIV))
767 volume->v_ad_options |= ADVOL_UNIXPRIV;
768 if ((volume->v_flags & AFPVOL_INV_DOTS))
769 volume->v_ad_options |= ADVOL_INVDOTS;
770 if ((volume->v_flags & AFPVOL_NOADOUBLE))
771 volume->v_ad_options |= ADVOL_NOADOUBLE;
774 volume->v_password = strdup(options[VOLOPT_PASSWORD].c_value);
777 volume->v_veto = strdup(options[VOLOPT_VETO].c_value);
780 volume->v_volcodepage = strdup(options[VOLOPT_ENCODING].c_value);
783 volume->v_maccodepage = strdup(options[VOLOPT_MACCHARSET].c_value);
786 volume->v_dbpath = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_DBPATH].c_value, pwd, path, name);
789 volume->v_cnidscheme = strdup(options[VOLOPT_CNIDSCHEME].c_value);
792 volume->v_cnidserver = strdup(options[VOLOPT_CNIDSERVER].c_value);
795 volume->v_cnidport = strdup(options[VOLOPT_CNIDPORT].c_value);
798 volume->v_umask = (mode_t)options[VOLOPT_UMASK].i_value;
801 volume->v_dperm = (mode_t)options[VOLOPT_DPERM].i_value;
804 volume->v_fperm = (mode_t)options[VOLOPT_FPERM].i_value;
807 volume->v_perm = (mode_t)options[VOLOPT_DFLTPERM].i_value;
810 volume->v_adouble = options[VOLOPT_ADOUBLE].i_value;
812 volume->v_adouble = AD_VERSION;
815 volume->v_limitsize = options[VOLOPT_LIMITSIZE].i_value;
818 volume->v_mtou_flags = 0;
819 if (!(volume->v_flags & AFPVOL_NOHEX))
820 volume->v_mtou_flags |= CONV_ESCAPEHEX;
821 if (!(volume->v_flags & AFPVOL_USEDOTS))
822 volume->v_mtou_flags |= CONV_ESCAPEDOTS;
823 if ((volume->v_flags & AFPVOL_EILSEQ))
824 volume->v_mtou_flags |= CONV__EILSEQ;
826 if ((volume->v_casefold & AFPVOL_MTOUUPPER))
827 volume->v_mtou_flags |= CONV_TOUPPER;
828 else if ((volume->v_casefold & AFPVOL_MTOULOWER))
829 volume->v_mtou_flags |= CONV_TOLOWER;
832 volume->v_utom_flags = CONV_IGNORE | CONV_UNESCAPEHEX;
833 if ((volume->v_casefold & AFPVOL_UTOMUPPER))
834 volume->v_utom_flags |= CONV_TOUPPER;
835 else if ((volume->v_casefold & AFPVOL_UTOMLOWER))
836 volume->v_utom_flags |= CONV_TOLOWER;
838 if ((volume->v_flags & AFPVOL_EILSEQ))
839 volume->v_utom_flags |= CONV__EILSEQ;
843 volume->v_forceuid = strdup(options[VOLOPT_FORCEUID].c_value);
845 volume->v_forceuid = NULL; /* set as null so as to return 0 later on */
849 volume->v_forcegid = strdup(options[VOLOPT_FORCEGID].c_value);
851 volume->v_forcegid = NULL; /* set as null so as to return 0 later on */
856 volume->v_preexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_PREEXEC].c_value, pwd, path, name);
857 volume->v_preexec_close = options[VOLOPT_PREEXEC].i_value;
860 volume->v_postexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_POSTEXEC].c_value, pwd, path, name);
863 volume->v_root_preexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_ROOTPREEXEC].c_value, pwd, path, name);
864 volume->v_root_preexec_close = options[VOLOPT_ROOTPREEXEC].i_value;
867 volume->v_root_postexec = volxlate(obj, NULL, MAXPATHLEN, options[VOLOPT_ROOTPOSTEXEC].c_value, pwd, path, name);
870 volume->v_dperm |= volume->v_perm;
871 volume->v_fperm |= volume->v_perm;
873 /* Check EA support on volume */
874 if (volume->v_vfs_ea == AFPVOL_EA_AUTO)
875 check_ea_sys_support(volume);
876 initvol_vfs(volume);
879 if ((parent_or_child == 0) && (volume->v_flags & AFPVOL_TM)) {
880 char *uuid = get_vol_uuid(obj, volume->v_localname);
883 volume->v_localname);
885 volume->v_uuid = uuid;
887 volume->v_localname, volume->v_uuid);
891 volume->v_next = Volumes;
892 Volumes = volume;
1024 LOG(log_info, logtype_afpd, "AFP access denied for client IP '%s' to volume '%s' by denied list",
1036 LOG(log_info, logtype_afpd, "AFP access denied for client IP '%s' to volume '%s', not in allowed list",
1157 * Read a volume configuration file and add the volumes contained within to
1158 * the global volume list. This gets called from the forked afpd childs.
1166 * <unix path> [<volume name>] [allow:<user>,<@group>,...] \
1208 /* try putting a read lock on the volume file twice, sleep 1 second if first attempt fails */
1214 LOG(log_error, logtype_afpd, "readvolfile: can't lock volume file \"%s\"", path);
1412 static void volume_unlink(struct vol *volume)
1416 if (volume == Volumes) {
1423 if (vol == volume) {
1454 * Calculate used size of a volume with nftw
1460 * 1b) - volume modification date is not yet set and the last time we've been called is
1462 * 1c) - the last volume modification is less then 30 sec old
1464 * @param vol (rw) volume to calculate
1539 LOG(log_debug, logtype_afpd, "volparams: used on volume: %" PRIu64 " bytes",
1569 * set volume creation date
1574 struct vol *volume;
1577 for ( volume = Volumes; volume; volume = volume->v_next ) {
1578 if (volume->v_vid == id) {
1579 vol = volume;
1581 else if ((time_t)(AD_DATE_FROM_UNIX(date)) == volume->v_ctime) {
1583 volume = Volumes; /* restart */
1811 /* save the volume device number */
1906 struct vol *volume;
1915 for ( vcnt = 0, volume = Volumes; volume; volume = volume->v_next ) {
1916 if (!(volume->v_flags & AFPVOL_NOSTAT)) {
1919 if ( stat( volume->v_path, &st ) < 0 ) {
1921 volume->v_path, strerror(errno) );
1927 accessmode(volume->v_path, &ma, NULL, &st);
1932 if (volume->v_hide) {
1933 continue; /* config file changed but the volume was mounted */
1937 len = ucs2_to_charset_allocate(CH_UTF8_MAC, &namebuf, volume->v_u8mname);
1939 len = ucs2_to_charset_allocate(obj->options.maccharset, &namebuf, volume->v_macname);
1945 /* set password bit if there's a volume password */
1946 *data = (volume->v_password) ? AFPSRVR_PASSWD : 0;
1948 /* Apple 2 clients running ProDOS-8 expect one volume to have
1954 *data |= (volume->v_flags & AFPVOL_A2VOL) ? AFPSRVR_CONFIGINFO : 0;
1966 LOG(log_error, logtype_afpd, "afp_getsrvrparms(%s): gettimeofday: %s", volume->v_path, strerror(errno) );
1978 static int volume_codepage(AFPObj *obj, struct vol *volume)
1983 if (!volume->v_volcodepage)
1984 volume->v_volcodepage = strdup("UTF8");
1986 if ( (charset_t) -1 == ( volume->v_volcharset = add_charset(volume->v_volcodepage)) ) {
1987 LOG (log_error, logtype_afpd, "Setting codepage %s as volume codepage failed", volume->v_volcodepage);
1991 if ( NULL == (charset = find_charset_functions(volume->v_volcodepage)) || charset->flags & CHARSET_ICONV ) {
1992 LOG (log_warning, logtype_afpd, "WARNING: volume encoding %s is *not* supported by netatalk, expect problems !!!!", volume->v_volcodepage);
1995 if (!volume->v_maccodepage)
1996 volume->v_maccodepage = strdup(obj->options.maccodepage);
1998 if ( (charset_t) -1 == ( volume->v_maccharset = add_charset(volume->v_maccodepage)) ) {
1999 LOG (log_error, logtype_afpd, "Setting codepage %s as mac codepage failed", volume->v_maccodepage);
2003 if ( NULL == ( charset = find_charset_functions(volume->v_maccodepage)) || ! (charset->flags & CHARSET_CLIENT) ) {
2004 LOG (log_error, logtype_afpd, "Fatal error: mac charset %s not supported", volume->v_maccodepage);
2007 volume->v_kTextEncoding = htonl(charset->kTextEncoding);
2012 static int volume_openDB(struct vol *volume)
2016 if ((volume->v_flags & AFPVOL_NODEV)) {
2020 if (volume->v_cnidscheme == NULL) {
2021 volume->v_cnidscheme = strdup(DEFAULT_CNID_SCHEME);
2023 volume->v_path, volume->v_cnidscheme);
2027 volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
2028 volume->v_cnidport ? volume->v_cnidport : Cnid_port);
2034 if (strcmp(volume->v_cnidscheme, "last") == 0) {
2036 volume->v_cnidscheme = strdup("tdb");
2041 if (volume->v_flags & AFPVOL_CDROM) {
2043 if (strcmp(volume->v_cnidscheme, "tdb") != 0) {
2044 free(volume->v_cnidscheme);
2045 volume->v_cnidscheme = strdup("tdb");
2047 volume->v_path, volume->v_cnidscheme);
2052 volume->v_cdb = cnid_open(volume->v_path,
2053 volume->v_umask,
2054 volume->v_cnidscheme,
2056 volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
2057 volume->v_cnidport ? volume->v_cnidport : Cnid_port);
2059 if ( ! volume->v_cdb && ! (flags & CNID_FLAG_MEMORY)) {
2061 LOG(log_error, logtype_afpd, "Can't open volume \"%s\" CNID backend \"%s\" ",
2062 volume->v_path, volume->v_cnidscheme);
2063 LOG(log_error, logtype_afpd, "Reopen volume %s using in memory temporary CNID DB.",
2064 volume->v_path);
2066 volume->v_cdb = cnid_open (volume->v_path, volume->v_umask, "tdb", flags, NULL, NULL);
2069 if (volume->v_cdb) {
2071 setmessage("Something wrong with the volume's CNID DB, using temporary CNID DB instead."
2076 volume->v_flags &= ~AFPVOL_CACHE;
2081 return (!volume->v_cdb)?-1:0;
2099 LOG(log_info, logtype_afpd, "read-only volume '%s', can't test for EA support, disabling EAs", vol->v_localname);
2117 LOG(log_warning, logtype_afpd, "volume \"%s\" does not support Extended Attributes, using ea:ad instead",
2140 struct vol *volume;
2182 for ( volume = Volumes; volume; volume = volume->v_next ) {
2183 if ( strcasecmp_w( (ucs2_t*) volname, volume->v_name ) == 0 ) {
2188 if ( volume == NULL ) {
2192 /* check for a volume password */
2193 if (volume->v_password && strncmp(ibuf, volume->v_password, VOLPASSLEN)) {
2197 if (( volume->v_flags & AFPVOL_OPEN ) ) {
2198 /* the volume is already open */
2200 set_uidgid ( volume );
2202 return stat_vol(bitmap, volume, rbuf, rbuflen);
2205 if (volume->v_root_preexec) {
2206 if ((ret = afprun(1, volume->v_root_preexec, NULL)) && volume->v_root_preexec_close) {
2207 LOG(log_error, logtype_afpd, "afp_openvol(%s): root preexec : %d", volume->v_path, ret );
2213 set_uidgid ( volume );
2216 if (volume->v_preexec) {
2217 if ((ret = afprun(0, volume->v_preexec, NULL)) && volume->v_preexec_close) {
2218 LOG(log_error, logtype_afpd, "afp_openvol(%s): preexec : %d", volume->v_path, ret );
2223 if ( stat( volume->v_path, &st ) < 0 ) {
2227 if ( chdir( volume->v_path ) < 0 ) {
2233 LOG(log_error, logtype_afpd, "afp_openvol(%s): volume pathlen too long", volume->v_path);
2237 /* Normalize volume path */
2239 if ((volume->v_path = realpath(path, NULL)) == NULL)
2242 if ((volume->v_path = malloc(MAXPATHLEN+1)) == NULL)
2244 if (realpath(path, volume->v_path) == NULL) {
2245 free(volume->v_path);
2250 if ((tmp = strdup(volume->v_path)) == NULL) {
2251 free(volume->v_path);
2254 free(volume->v_path);
2255 volume->v_path = tmp;
2258 if (volume_codepage(obj, volume) < 0) {
2263 /* initialize volume variables
2267 volume->max_filename = UTF8FILELEN_EARLY;
2270 volume->max_filename = MACFILELEN;
2273 volume->v_flags |= AFPVOL_OPEN;
2274 volume->v_cdb = NULL;
2277 len = convert_string_allocate(CH_UCS2, CH_UTF8_MAC, volume->v_u8mname, namelen, &vol_mname);
2279 len = convert_string_allocate(CH_UCS2, obj->options.maccharset, volume->v_macname, namelen, &vol_mname);
2293 volume,
2296 bfromcstr(volume->v_path),
2300 LOG(log_error, logtype_afpd, "afp_openvol(%s): malloc: %s", volume->v_path, strerror(errno) );
2305 volume->v_root = dir;
2308 if (volume_openDB(volume) < 0) {
2310 volume->v_path, volume->v_cnidscheme);
2315 ret = stat_vol(bitmap, volume, rbuf, rbuflen);
2318 if (!(volume->v_flags & AFPVOL_RO)) {
2319 handle_special_folders( volume );
2320 savevolinfo(volume,
2321 volume->v_cnidserver ? volume->v_cnidserver : Cnid_srv,
2322 volume->v_cnidport ? volume->v_cnidport : Cnid_port);
2326 * If you mount a volume twice, the second time the trash appears on
2333 if ((volume->v_cdb->flags & CNID_FLAG_PERSISTENT)) {
2336 if (cnid_getstamp(volume->v_cdb, volume->v_stamp, sizeof(volume->v_stamp)) < 0) {
2339 volume->v_path);
2346 cname( volume, volume->v_root, &p );
2352 if (volume->v_root) {
2353 dir_free( volume->v_root );
2354 volume->v_root = NULL;
2357 volume->v_flags &= ~AFPVOL_OPEN;
2358 if (volume->v_cdb != NULL) {
2359 cnid_close(volume->v_cdb);
2360 volume->v_cdb = NULL;
2503 poll if a volume is changed by other processes.
2660 * this is only intended for folders in the volume root
2799 continue; /* another volume name */