~ubuntu-branches/ubuntu/saucy/lvm2/saucy-proposed

« back to all changes in this revision

Viewing changes to lib/format_text/export.c

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2012-08-14 14:35:57 UTC
  • mfrom: (3.1.25 sid)
  • Revision ID: package-import@ubuntu.com-20120814143557-93aill2tp3kf3o30
Tags: 2.02.95-4ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/patches/avoid-dev-block.patch: Prefer any other device name over
    names in /dev/block/ since lvm.conf won't handle this.
  - debian/rules:
    - copy .po file to .pot file for Rosetta (Ubuntu specific).
  - debian/{dmsetup,lvm2}-udeb.install:
    - install initramfs and udev hooks in udebs (Debian bug 504341).
  - auto-start VGs as their PVs are discovered (Ubuntu specific):
    - add debian/tree/lvm2/lib/udev/rules.d/85-lvm2.rules: use watershed plus
      the sledgehammer of vgscan/vgchange to turn on VGs as they come online.
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/hooks/lvm2:
      - add 85-lvm2.rules to the list of udev rules to copy.
      - depend on udev.
    - debian/control:
      - add versioned Depend on watershed in lvm2 for udev rules.
      - add Depends on watershed-udeb in lvm2-udeb for udev rules.
      - add versioned Depend/Breaks on udev in dmsetup for udev rules.
      - add Depend on initramfs-tools in dmsetup so system is not potentially
        rendered unbootable by out-of-order dpkg configuration.
    - debian/rules:
      - do not install local-top scripts since Ubuntu mounts root using udev.
      - do not install init scripts for lvm2, since udev starts LVM.
    - debian/lvm2.postinst: handle missing lvm2 init script.
    - debian/tree/dmsetup/lib/udev/rules.d/60-persistent-storage-dm.rules:
      watch dm devices for changes with inotify
  - add mountroot failure hooks to help fix bad boots (Debian bug 468115):
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/init-premount/lvm2
  - remaining changes to upstream event manager packages (Debian bug 514706):
    - debian/rules:
      - enable dmeventd during configure.
    - debian/dmeventd.{8,manpages}: install dmeventd files.
  - rename debian/clvm.defaults to debian/clvm.default so it is installed
    correctly.
  - debian/control: add dmsetup-udeb to libdevmapper1.02.1-udeb recommends.
  - debian/rules: make sure dmsetup and lvm2 initramfs-tools scripts are
    executable.  When the Ubuntu-specific ones are added with a patch,
    they may lose their executable bit.
  - Add and install clvmd resource agent
  - Add dependency on libudev-dev to libdevmapper-dev so that the .pc file
    works.
  - debian/{clvmd.ra,clvm.init}:
    - create /run/lvm if it doesn't exist.
  - debian/clvm.init:
    - exit 3 if not running on status action.
  - Call dh_installman so that our dmeventd manpage actually gets installed
  - Install the missing fsadm manpage.

 * libdevmapper-dev:
  - move .so symlinks and pkgconfig files to multiarched locations.
  - mark libdevmapper-dev M-A: same

 * libdevmapper-event1.02.1:
  - Add Breaks: dmeventd (<< 2.02.95-4ubuntu1) due to debian symbol rename

 * debian/lvm2.{preinst,postinst,postrm}:
  - Implement removal of obsolete /etc/init.d/lvm2 conffile, which
    should not have been re-introduced in Quantal.

 * Dropped Changes, included in Debian:
  - Mostly included packages for upstream event manager (Debian bug 514706).
  - debian/patches/rules-subdir.patch: removed as reordering will cause
    build failure with dmeventd.
  - debian/patches/libdm-event-static.patch: removed as other static libs
    aren't being built anymore either.
  - Update symbols for libdevmapper-event.
  - Update libdevmapper-event, dmeventd descriptions to match Debian
    boilerplate.

 * Disappeared Changes:
  - Don't install documentation in udebs. No diff found, but no docs are
    installed into udebs either.

 * Resurected Changes:
  - corrected dropping the wrong init script. Now clvm.init is shipped
    and lvm2.init is dropped in favor of udev rules as per original
    intention (LP: #1037033).

Show diffs side-by-side

added added

removed removed

Lines of Context:
319
319
        return out_text(f, "%s", line);
320
320
}
321
321
 
322
 
int out_config_node(struct formatter *f, const struct config_node *cn)
 
322
int out_config_node(struct formatter *f, const struct dm_config_node *cn)
323
323
{
324
 
        return write_config_node(cn, _out_line, f);
 
324
        return dm_config_write_node(cn, _out_line, f);
325
325
}
326
326
 
327
327
static int _print_header(struct formatter *f,
337
337
        outf(f, FORMAT_VERSION_FIELD " = %d", FORMAT_VERSION_VALUE);
338
338
        outnl(f);
339
339
 
340
 
        if (!(buf = alloca(escaped_len(desc)))) {
 
340
        if (!(buf = alloca(dm_escaped_len(desc)))) {
341
341
                log_error("temporary stack allocation for description"
342
342
                          "string failed");
343
343
                return 0;
344
344
        }
345
 
        outf(f, "description = \"%s\"", escape_double_quotes(buf, desc));
 
345
        outf(f, "description = \"%s\"", dm_escape_double_quotes(buf, desc));
346
346
        outnl(f);
347
347
        outf(f, "creation_host = \"%s\"\t# %s %s %s %s %s", _utsname.nodename,
348
348
             _utsname.sysname, _utsname.nodename, _utsname.release,
395
395
 
396
396
        outf(f, "seqno = %u", vg->seqno);
397
397
 
 
398
        if (vg->fid && vg->fid->fmt)
 
399
                outf(f, "format = \"%s\" # informational", vg->fid->fmt->name);
 
400
 
398
401
        if (!_print_flag_config(f, vg->status, VG_FLAGS))
399
402
                return_0;
400
403
 
465
468
 
466
469
                outf(f, "id = \"%s\"", buffer);
467
470
 
468
 
                if (!(buf = alloca(escaped_len(pv_dev_name(pv))))) {
 
471
                if (!(buf = alloca(dm_escaped_len(pv_dev_name(pv))))) {
469
472
                        log_error("temporary stack allocation for device name"
470
473
                                  "string failed");
471
474
                        return 0;
472
475
                }
473
476
 
474
477
                outhint(f, "device = \"%s\"",
475
 
                        escape_double_quotes(buf, pv_dev_name(pv)));
 
478
                        dm_escape_double_quotes(buf, pv_dev_name(pv)));
476
479
                outnl(f);
477
480
 
478
481
                if (!_print_flag_config(f, pv->status, PV_FLAGS))
579
582
        struct lv_segment *seg;
580
583
        char buffer[4096];
581
584
        int seg_count;
 
585
        struct tm *local_tm;
 
586
        time_t ts;
582
587
 
583
588
        outnl(f);
584
589
        outf(f, "%s {", lv->name);
596
601
        if (!_out_tags(f, &lv->tags))
597
602
                return_0;
598
603
 
 
604
        if (lv->timestamp) {
 
605
                ts = (time_t)lv->timestamp;
 
606
                strncpy(buffer, "# ", sizeof(buffer));
 
607
                if (!(local_tm = localtime(&ts)) ||
 
608
                    !strftime(buffer + 2, sizeof(buffer) - 2,
 
609
                              "%Y-%m-%d %T %z", local_tm))
 
610
                        buffer[0] = 0;
 
611
 
 
612
                outf(f, "creation_host = \"%s\"", lv->hostname);
 
613
                outfc(f, buffer, "creation_time = %" PRIu64,
 
614
                      lv->timestamp);
 
615
        }
 
616
 
599
617
        if (lv->alloc != ALLOC_INHERIT)
600
618
                outf(f, "allocation_policy = \"%s\"",
601
619
                     get_alloc_string(lv->alloc));
742
760
        r = 1;
743
761
 
744
762
      out:
745
 
        if (f->mem)
 
763
        if (f->mem) {
746
764
                dm_pool_destroy(f->mem);
 
765
                f->mem = NULL;
 
766
        }
747
767
 
748
 
        if (f->pv_names)
 
768
        if (f->pv_names) {
749
769
                dm_hash_destroy(f->pv_names);
 
770
                f->pv_names = NULL;
 
771
        }
750
772
 
751
773
        return r;
752
774
}
775
797
}
776
798
 
777
799
/* Returns amount of buffer used incl. terminating NUL */
778
 
int text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf)
 
800
size_t text_vg_export_raw(struct volume_group *vg, const char *desc, char **buf)
779
801
{
780
802
        struct formatter *f;
781
 
        int r = 0;
 
803
        size_t r = 0;
782
804
 
783
805
        _init();
784
806
 
809
831
        return r;
810
832
}
811
833
 
812
 
int export_vg_to_buffer(struct volume_group *vg, char **buf)
 
834
size_t export_vg_to_buffer(struct volume_group *vg, char **buf)
813
835
{
814
836
        return text_vg_export_raw(vg, "", buf);
815
837
}