Deleted Added
full compact
parse.y (225784) parse.y (225830)
1%{
2/*-
3 * Copyright (c) 2009-2010 The FreeBSD Foundation
4 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
5 * All rights reserved.
6 *
7 * This software was developed by Pawel Jakub Dawidek under sponsorship from
8 * the FreeBSD Foundation.

--- 14 unchanged lines hidden (view full) ---

23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
1%{
2/*-
3 * Copyright (c) 2009-2010 The FreeBSD Foundation
4 * Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>
5 * All rights reserved.
6 *
7 * This software was developed by Pawel Jakub Dawidek under sponsorship from
8 * the FreeBSD Foundation.

--- 14 unchanged lines hidden (view full) ---

23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $FreeBSD: head/sbin/hastd/parse.y 225784 2011-09-27 08:04:01Z pjd $
31 * $FreeBSD: head/sbin/hastd/parse.y 225830 2011-09-28 13:08:51Z pjd $
32 */
33
34#include <sys/param.h> /* MAXHOSTNAMELEN */
35#include <sys/queue.h>
36#include <sys/socket.h>
37#include <sys/sysctl.h>
38
39#include <arpa/inet.h>

--- 23 unchanged lines hidden (view full) ---

63static char depth0_listen_tcp4[HAST_ADDRSIZE];
64static char depth0_listen_tcp6[HAST_ADDRSIZE];
65static TAILQ_HEAD(, hastd_listen) depth0_listen;
66static int depth0_replication;
67static int depth0_checksum;
68static int depth0_compression;
69static int depth0_timeout;
70static char depth0_exec[PATH_MAX];
32 */
33
34#include <sys/param.h> /* MAXHOSTNAMELEN */
35#include <sys/queue.h>
36#include <sys/socket.h>
37#include <sys/sysctl.h>
38
39#include <arpa/inet.h>

--- 23 unchanged lines hidden (view full) ---

63static char depth0_listen_tcp4[HAST_ADDRSIZE];
64static char depth0_listen_tcp6[HAST_ADDRSIZE];
65static TAILQ_HEAD(, hastd_listen) depth0_listen;
66static int depth0_replication;
67static int depth0_checksum;
68static int depth0_compression;
69static int depth0_timeout;
70static char depth0_exec[PATH_MAX];
71static int depth0_metaflush;
71
72static char depth1_provname[PATH_MAX];
73static char depth1_localpath[PATH_MAX];
72
73static char depth1_provname[PATH_MAX];
74static char depth1_localpath[PATH_MAX];
75static int depth1_metaflush;
74
75extern void yyrestart(FILE *);
76
77static int
78isitme(const char *name)
79{
80 char buf[MAXHOSTNAMELEN];
81 char *pos;

--- 110 unchanged lines hidden (view full) ---

192 depth0_compression = HAST_COMPRESSION_HOLE;
193 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
194 TAILQ_INIT(&depth0_listen);
195 strlcpy(depth0_listen_tcp4, HASTD_LISTEN_TCP4,
196 sizeof(depth0_listen_tcp4));
197 strlcpy(depth0_listen_tcp6, HASTD_LISTEN_TCP6,
198 sizeof(depth0_listen_tcp6));
199 depth0_exec[0] = '\0';
76
77extern void yyrestart(FILE *);
78
79static int
80isitme(const char *name)
81{
82 char buf[MAXHOSTNAMELEN];
83 char *pos;

--- 110 unchanged lines hidden (view full) ---

194 depth0_compression = HAST_COMPRESSION_HOLE;
195 strlcpy(depth0_control, HAST_CONTROL, sizeof(depth0_control));
196 TAILQ_INIT(&depth0_listen);
197 strlcpy(depth0_listen_tcp4, HASTD_LISTEN_TCP4,
198 sizeof(depth0_listen_tcp4));
199 strlcpy(depth0_listen_tcp6, HASTD_LISTEN_TCP6,
200 sizeof(depth0_listen_tcp6));
201 depth0_exec[0] = '\0';
202 depth0_metaflush = 1;
200
201 lconfig = calloc(1, sizeof(*lconfig));
202 if (lconfig == NULL) {
203 pjdlog_error("Unable to allocate memory for configuration.");
204 if (exitonerror)
205 exit(EX_TEMPFAIL);
206 return (NULL);
207 }

--- 115 unchanged lines hidden (view full) ---

323 if (curres->hr_exec[0] == '\0') {
324 /*
325 * Exec is not set at resource-level.
326 * Use global or default setting.
327 */
328 strlcpy(curres->hr_exec, depth0_exec,
329 sizeof(curres->hr_exec));
330 }
203
204 lconfig = calloc(1, sizeof(*lconfig));
205 if (lconfig == NULL) {
206 pjdlog_error("Unable to allocate memory for configuration.");
207 if (exitonerror)
208 exit(EX_TEMPFAIL);
209 return (NULL);
210 }

--- 115 unchanged lines hidden (view full) ---

326 if (curres->hr_exec[0] == '\0') {
327 /*
328 * Exec is not set at resource-level.
329 * Use global or default setting.
330 */
331 strlcpy(curres->hr_exec, depth0_exec,
332 sizeof(curres->hr_exec));
333 }
334 if (curres->hr_metaflush == -1) {
335 /*
336 * Metaflush is not set at resource-level.
337 * Use global or default setting.
338 */
339 curres->hr_metaflush = depth0_metaflush;
340 }
331 }
332
333 return (lconfig);
334}
335
336void
337yy_config_free(struct hastd_config *config)
338{

--- 11 unchanged lines hidden (view full) ---

350 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
351 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
352 free(res);
353 }
354 free(config);
355}
356%}
357
341 }
342
343 return (lconfig);
344}
345
346void
347yy_config_free(struct hastd_config *config)
348{

--- 11 unchanged lines hidden (view full) ---

360 while ((res = TAILQ_FIRST(&config->hc_resources)) != NULL) {
361 TAILQ_REMOVE(&config->hc_resources, res, hr_next);
362 free(res);
363 }
364 free(config);
365}
366%}
367
358%token CONTROL LISTEN PORT REPLICATION CHECKSUM COMPRESSION
359%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE SOURCE ON
368%token CONTROL LISTEN PORT REPLICATION CHECKSUM COMPRESSION METAFLUSH
369%token TIMEOUT EXEC EXTENTSIZE RESOURCE NAME LOCAL REMOTE SOURCE ON OFF
360%token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF
361%token NUM STR OB CB
362
363%type <str> remote_str
364%type <num> replication_type
365%type <num> checksum_type
366%type <num> compression_type
370%token FULLSYNC MEMSYNC ASYNC NONE CRC32 SHA256 HOLE LZF
371%token NUM STR OB CB
372
373%type <str> remote_str
374%type <num> replication_type
375%type <num> checksum_type
376%type <num> compression_type
377%type <num> boolean
367
368%union
369{
370 int num;
371 char *str;
372}
373
374%token <num> NUM

--- 16 unchanged lines hidden (view full) ---

391 checksum_statement
392 |
393 compression_statement
394 |
395 timeout_statement
396 |
397 exec_statement
398 |
378
379%union
380{
381 int num;
382 char *str;
383}
384
385%token <num> NUM

--- 16 unchanged lines hidden (view full) ---

402 checksum_statement
403 |
404 compression_statement
405 |
406 timeout_statement
407 |
408 exec_statement
409 |
410 metaflush_statement
411 |
399 node_statement
400 |
401 resource_statement
402 ;
403
404control_statement: CONTROL STR
405 {
406 switch (depth) {

--- 173 unchanged lines hidden (view full) ---

580 break;
581 default:
582 PJDLOG_ABORT("exec at wrong depth level");
583 }
584 free($2);
585 }
586 ;
587
412 node_statement
413 |
414 resource_statement
415 ;
416
417control_statement: CONTROL STR
418 {
419 switch (depth) {

--- 173 unchanged lines hidden (view full) ---

593 break;
594 default:
595 PJDLOG_ABORT("exec at wrong depth level");
596 }
597 free($2);
598 }
599 ;
600
601metaflush_statement: METAFLUSH boolean
602 {
603 switch (depth) {
604 case 0:
605 depth0_metaflush = $2;
606 break;
607 case 1:
608 PJDLOG_ASSERT(curres != NULL);
609 depth1_metaflush = $2;
610 break;
611 case 2:
612 if (!mynode)
613 break;
614 PJDLOG_ASSERT(curres != NULL);
615 curres->hr_metaflush = $2;
616 break;
617 default:
618 PJDLOG_ABORT("metaflush at wrong depth level");
619 }
620 }
621 ;
622
623boolean:
624 ON { $$ = 1; }
625 |
626 OFF { $$ = 0; }
627 ;
628
588node_statement: ON node_start OB node_entries CB
589 {
590 mynode = false;
591 }
592 ;
593
594node_start: STR
595 {

--- 59 unchanged lines hidden (view full) ---

655 /*
656 * Path to local provider is not set at
657 * node-level, but is set at resource-level,
658 * use it.
659 */
660 strlcpy(curres->hr_localpath, depth1_localpath,
661 sizeof(curres->hr_localpath));
662 }
629node_statement: ON node_start OB node_entries CB
630 {
631 mynode = false;
632 }
633 ;
634
635node_start: STR
636 {

--- 59 unchanged lines hidden (view full) ---

696 /*
697 * Path to local provider is not set at
698 * node-level, but is set at resource-level,
699 * use it.
700 */
701 strlcpy(curres->hr_localpath, depth1_localpath,
702 sizeof(curres->hr_localpath));
703 }
704 if (curres->hr_metaflush == -1 && depth1_metaflush != -1) {
705 /*
706 * Metaflush is not set at node-level,
707 * but is set at resource-level, use it.
708 */
709 curres->hr_metaflush = depth1_metaflush;
710 }
663
664 /*
665 * If provider name is not given, use resource name
666 * as provider name.
667 */
668 if (curres->hr_provname[0] == '\0') {
669 strlcpy(curres->hr_provname, curres->hr_name,
670 sizeof(curres->hr_provname));

--- 37 unchanged lines hidden (view full) ---

708 }
709
710 /*
711 * Clear those, so we can tell if they were set at
712 * resource-level or not.
713 */
714 depth1_provname[0] = '\0';
715 depth1_localpath[0] = '\0';
711
712 /*
713 * If provider name is not given, use resource name
714 * as provider name.
715 */
716 if (curres->hr_provname[0] == '\0') {
717 strlcpy(curres->hr_provname, curres->hr_name,
718 sizeof(curres->hr_provname));

--- 37 unchanged lines hidden (view full) ---

756 }
757
758 /*
759 * Clear those, so we can tell if they were set at
760 * resource-level or not.
761 */
762 depth1_provname[0] = '\0';
763 depth1_localpath[0] = '\0';
764 depth1_metaflush = -1;
716 hadmynode = false;
717
718 curres = calloc(1, sizeof(*curres));
719 if (curres == NULL) {
720 pjdlog_error("Unable to allocate memory for resource.");
721 free($1);
722 return (1);
723 }

--- 10 unchanged lines hidden (view full) ---

734 curres->hr_replication = -1;
735 curres->hr_checksum = -1;
736 curres->hr_compression = -1;
737 curres->hr_timeout = -1;
738 curres->hr_exec[0] = '\0';
739 curres->hr_provname[0] = '\0';
740 curres->hr_localpath[0] = '\0';
741 curres->hr_localfd = -1;
765 hadmynode = false;
766
767 curres = calloc(1, sizeof(*curres));
768 if (curres == NULL) {
769 pjdlog_error("Unable to allocate memory for resource.");
770 free($1);
771 return (1);
772 }

--- 10 unchanged lines hidden (view full) ---

783 curres->hr_replication = -1;
784 curres->hr_checksum = -1;
785 curres->hr_compression = -1;
786 curres->hr_timeout = -1;
787 curres->hr_exec[0] = '\0';
788 curres->hr_provname[0] = '\0';
789 curres->hr_localpath[0] = '\0';
790 curres->hr_localfd = -1;
791 curres->hr_metaflush = -1;
742 curres->hr_remoteaddr[0] = '\0';
743 curres->hr_sourceaddr[0] = '\0';
744 curres->hr_ggateunit = -1;
745 }
746 ;
747
748resource_entries:
749 |

--- 6 unchanged lines hidden (view full) ---

756 checksum_statement
757 |
758 compression_statement
759 |
760 timeout_statement
761 |
762 exec_statement
763 |
792 curres->hr_remoteaddr[0] = '\0';
793 curres->hr_sourceaddr[0] = '\0';
794 curres->hr_ggateunit = -1;
795 }
796 ;
797
798resource_entries:
799 |

--- 6 unchanged lines hidden (view full) ---

806 checksum_statement
807 |
808 compression_statement
809 |
810 timeout_statement
811 |
812 exec_statement
813 |
814 metaflush_statement
815 |
764 name_statement
765 |
766 local_statement
767 |
768 resource_node_statement
769 ;
770
771name_statement: NAME STR

--- 92 unchanged lines hidden (view full) ---

864resource_node_entry:
865 name_statement
866 |
867 local_statement
868 |
869 remote_statement
870 |
871 source_statement
816 name_statement
817 |
818 local_statement
819 |
820 resource_node_statement
821 ;
822
823name_statement: NAME STR

--- 92 unchanged lines hidden (view full) ---

916resource_node_entry:
917 name_statement
918 |
919 local_statement
920 |
921 remote_statement
922 |
923 source_statement
924 |
925 metaflush_statement
872 ;
873
874remote_statement: REMOTE remote_str
875 {
876 PJDLOG_ASSERT(depth == 2);
877 if (mynode) {
878 PJDLOG_ASSERT(curres != NULL);
879 if (strlcpy(curres->hr_remoteaddr, $2,

--- 33 unchanged lines hidden ---
926 ;
927
928remote_statement: REMOTE remote_str
929 {
930 PJDLOG_ASSERT(depth == 2);
931 if (mynode) {
932 PJDLOG_ASSERT(curres != NULL);
933 if (strlcpy(curres->hr_remoteaddr, $2,

--- 33 unchanged lines hidden ---