2007-12-12 14:39:32

by Alon Bar-Lev

[permalink] [raw]
Subject: ldminfo compilation

Hello,

I need to compile the ldminfo utility of linux-ntfs's package
linux-ldm. I need this as static or uclibc based.

The author stated in the Documentation/filesystems/ntfs.txt:
"""You will find the precompiled (i386) ldminfo utility there. NOTE:
You will not be able to compile this yourself easily so use the binary
version!"""

I don't like to use binary versions, but this is not so important....
I cannot use this dynamic linked x86 anyway.

Looking at the sources, it seems that the linux headers used in order
to build this are out of date...

Has anyone succeeded in compiling this? Are there alternatives? I need
to extract the information from ldm partition in order to dmsetup it
correctly.

I've contacted the author, Richard Russon <[email protected]> but got no response.

Best Regards,
Alon Bar-Lev.


2007-12-12 14:52:56

by Luciano Rocha

[permalink] [raw]
Subject: Re: ldminfo compilation

On Wed, Dec 12, 2007 at 04:39:18PM +0200, Alon Bar-Lev wrote:
> Hello,
>
> I need to compile the ldminfo utility of linux-ntfs's package
> linux-ldm. I need this as static or uclibc based.
>
> The author stated in the Documentation/filesystems/ntfs.txt:
> """You will find the precompiled (i386) ldminfo utility there. NOTE:
> You will not be able to compile this yourself easily so use the binary
> version!"""
>
> I don't like to use binary versions, but this is not so important....
> I cannot use this dynamic linked x86 anyway.
>
> Looking at the sources, it seems that the linux headers used in order
> to build this are out of date...

Those are for the kernel module setting the partition tables. If you're
only interested in the ldminfo utility:
make -C ldmutil CPP='g++ -static'

Substitute g++ for the C++ compiler you want to use.

--
Luciano Rocha <[email protected]>
Eurotux Inform?tica, S.A. <http://www.eurotux.com/>


Attachments:
(No filename) (941.00 B)
(No filename) (189.00 B)
Download all attachments

2007-12-12 15:03:56

by Alon Bar-Lev

[permalink] [raw]
Subject: Re: ldminfo compilation

On 12/12/07, Luciano Rocha <[email protected]> wrote:
> Those are for the kernel module setting the partition tables. If you're
> only interested in the ldminfo utility:
> make -C ldmutil CPP='g++ -static'
>
> Substitute g++ for the C++ compiler you want to use.

Hi!
Thank you for your reply!

I don't really understand how to use the output of ldmutil in order to
do the dmsetup... All the instructions are for ldminfo...

And the C++ dependency does not work well with uclibc... I tried to
compile this using uclibc++, but the exception handling of uclibc++ is
broken for some strange reason... And I don't wish to introduce the
overhead of the C++ libraries to my system...

If ldmutil contain all the information, I will backport this to C and
be happy... :)
Can you please tell me how you use the output of this utility to merge
a spanned partition on two separate disks?

Best Regards,
Alon Bar-Lev.

2007-12-12 15:30:17

by Luciano Rocha

[permalink] [raw]
Subject: Re: ldminfo compilation

On Wed, Dec 12, 2007 at 04:57:39PM +0200, Alon Bar-Lev wrote:
> On 12/12/07, Luciano Rocha <[email protected]> wrote:
> > Those are for the kernel module setting the partition tables. If you're
> > only interested in the ldminfo utility:
> > make -C ldmutil CPP='g++ -static'
> >
> > Substitute g++ for the C++ compiler you want to use.
>
> Hi!
> Thank you for your reply!
>
> I don't really understand how to use the output of ldmutil in order to
> do the dmsetup... All the instructions are for ldminfo...

Ah, sorry. Somehow I got the impression that the ldmutil directory
included the ldminfo binary. I'll see if I can compile the ldminfo
statically in an older system I have.

>
> And the C++ dependency does not work well with uclibc... I tried to
> compile this using uclibc++, but the exception handling of uclibc++ is
> broken for some strange reason... And I don't wish to introduce the
> overhead of the C++ libraries to my system...
>
> If ldmutil contain all the information, I will backport this to C and
> be happy... :)
> Can you please tell me how you use the output of this utility to merge
> a spanned partition on two separate disks?

I don't have a Windows dynamic disk, so I can't imagine out to convert
the output for dmsetup. Do you have a sample output?

--
Luciano Rocha <[email protected]>
Eurotux Inform?tica, S.A. <http://www.eurotux.com/>


Attachments:
(No filename) (1.35 kB)
(No filename) (189.00 B)
Download all attachments

2007-12-12 16:41:26

by Luciano Rocha

[permalink] [raw]
Subject: Re: ldminfo compilation

On Wed, Dec 12, 2007 at 03:29:55PM +0000, Luciano Rocha wrote:
> On Wed, Dec 12, 2007 at 04:57:39PM +0200, Alon Bar-Lev wrote:
> > On 12/12/07, Luciano Rocha <[email protected]> wrote:
> > > Those are for the kernel module setting the partition tables. If you're
> > > only interested in the ldminfo utility:
> > > make -C ldmutil CPP='g++ -static'
> > >
> > > Substitute g++ for the C++ compiler you want to use.
> >
> > Hi!
> > Thank you for your reply!
> >
> > I don't really understand how to use the output of ldmutil in order to
> > do the dmsetup... All the instructions are for ldminfo...
>
> Ah, sorry. Somehow I got the impression that the ldmutil directory
> included the ldminfo binary. I'll see if I can compile the ldminfo
> statically in an older system I have.

OK, the statically compiled version is at:
ftp://gil.di.uminho.pt/pub/users/strange/ldminfo
sha1sum: 71c1451f9cbd1a4256bb072d4c930418acc8e2fb

Anyway, how to compile with the sources of:
- linux-2.4.20
- linux-ldm-0.0.8

ldm=linux-ldm-0.0.8
kernel=linux-2.4.20

1. Decompress linux-ldm-0.0.8:
curl -s http://dl.sourceforge.net/sourceforge/linux-ntfs/$ldm.tar.bz2 \
| tar xjf -

2. Enter the directory:
cd $ldm

3. Decompress the Linux kernel sources:
curl -s ftp://ftp.di.uminho.pt/pub/kernel/v2.4/$kernel.tar.bz2 \
| tar xjf -

4. Change test/Makefile to compile ldminfo statically:
sed -e 's/ -o/ -static &/' -i test/Makefile

5. Correct KERNEL path in Makefile:
sed -e "s,KERNEL.*=.*,KERNEL = $PWD/$kernel," -i Makefile

6. Force i386 arch in Makefile:
sed -e 's/-march=.*/-march=i386/' -i Makefile

7. Generate kernel's option files:
yes n | make -C $kernel ARCH=i386 oldconfig dep

8. Compile ldminfo and ldmutil:
make ARCH=i386

This worked on a Centos 3.8, 32bits but running x86_64 kernel, but not
on my Fedora 8. YMMV.

Shell script:

ldm=linux-ldm-0.0.8
kernel=linux-2.4.20
curl -s http://dl.sourceforge.net/sourceforge/linux-ntfs/$ldm.tar.bz2 \
| tar xjf - &&
cd $ldm &&
curl -s ftp://ftp.di.uminho.pt/pub/kernel/v2.4/$kernel.tar.bz2 \
| tar xjf - &&
sed -e 's/ -o/ -static &/' -i test/Makefile &&
sed -e "s,KERNEL.*=.*,KERNEL = $PWD/$kernel," -i Makefile &&
sed -e 's/-march=.*/-march=i386/' -i Makefile &&
yes n | make -C $kernel ARCH=i386 oldconfig dep &&
make ARCH=i386

--
Luciano Rocha <[email protected]>
Eurotux Inform?tica, S.A. <http://www.eurotux.com/>


Attachments:
(No filename) (2.35 kB)
(No filename) (189.00 B)
Download all attachments

2007-12-12 22:59:22

by Alon Bar-Lev

[permalink] [raw]
Subject: Re: ldminfo compilation

On Wednesday 12 December 2007, Luciano Rocha wrote:
> Anyway, how to compile with the sources of:

Thank you so much!!!!
I didn't think of using 2.4 headers... bad me!

Anyway, I can now hack this to compile with uclibc...
I don't know if it works yet, but at least it builds now (26KB)

I had to use newer kernel, as I had some gcc related errors in include/asm/processor.h
and CONFIG_SMP related conflicts.

I truly hope maintainer will find some time to make it regular 2.6.X user mode
application... There are many packages that use kernel headers, but are much
easier to build, without sharing one object between kernel and userspace.

Best Regards,
Alon Bar-Lev

So just for the record...

I am using the following script to build:

ldm=linux-ldm-0.0.8
kernel=linux-2.4.35.4
wget --continue http://downloads.sourceforge.net/linux-ntfs/$ldm.tar.bz2
wget --continue http://www.kernel.org/pub/linux/kernel/v2.4/$kernel.tar.bz2
tar xjf $ldm.tar.bz2
cd $ldm
patch -p1 < ../$ldm-build.diff
tar xjf ../$kernel.tar.bz2
yes n | make -C $kernel ARCH=i386 oldconfig dep
make clean
make KERNEL=$(pwd)/$kernel LDMINFO_LDFLAGS=-static
#make KERNEL=$(pwd)/$kernel LDMINFO_CC=i586-pc-linux-uclibc-gcc

And the following patch:

---

diff -urNp linux-ldm-0.0.8.org/Makefile linux-ldm-0.0.8/Makefile
--- linux-ldm-0.0.8.org/Makefile 2002-03-09 03:58:42.000000000 +0200
+++ linux-ldm-0.0.8/Makefile 2007-12-13 00:38:09.000000000 +0200
@@ -27,7 +27,14 @@ CFLAGS += -fomit-frame-pointer
CFLAGS += -fno-strict-aliasing
CFLAGS += -pipe
CFLAGS += -mpreferred-stack-boundary=2
-CFLAGS += -march=$(shell uname -m)
+
+# libc fixups
+
+CFLAGS += -D__off_t_defined
+CFLAGS += -D__sigset_t_defined
+CFLAGS += -D_TIME_H
+CFLAGS += -D__defined_schedparam
+CFLAGS += -D__sched_param=sched_param

# ld flags

diff -urNp linux-ldm-0.0.8.org/test/compat.c linux-ldm-0.0.8/test/compat.c
--- linux-ldm-0.0.8.org/test/compat.c 2002-08-05 18:46:51.000000000 +0300
+++ linux-ldm-0.0.8/test/compat.c 2007-12-13 00:38:09.000000000 +0200
@@ -171,7 +171,7 @@ unsigned char *read_dev_sector (struct b
return bh->b_data;
}

-void __free_pages(struct page *page, unsigned int order)
+FASTCALL() void __free_pages(struct page *page, unsigned int order)
{
atomic_dec (&page->count);
if (atomic_read (&page->count) < 1) {
diff -urNp linux-ldm-0.0.8.org/test/Makefile linux-ldm-0.0.8/test/Makefile
--- linux-ldm-0.0.8.org/test/Makefile 2002-02-23 18:38:51.000000000 +0200
+++ linux-ldm-0.0.8/test/Makefile 2007-12-13 00:39:58.000000000 +0200
@@ -8,6 +8,8 @@ INFODEP = $(LDMDEP) compat.o copy.o dump

OUT = ldminfo sparse

+LDMINFO_CC = $(CC)
+
CFLAGS += -include extra.h
CFLAGS += -I$(KERNEL)/include
CFLAGS += -I$(KERNEL)/fs/partitions
@@ -15,13 +17,13 @@ CFLAGS += -I$(KERNEL)/fs/partitions
all: $(OUT)

.c.o:
- $(CC) $(CFLAGS) -c $< -o $@
+ $(LDMINFO_CC) $(CFLAGS) -c $< -o $@

ldminfo: $(INFODEP)
- $(CC) -o ldminfo $(INFODEP)
+ $(LDMINFO_CC) $(LDMINFO_LDFLAGS) -o ldminfo $(INFODEP)

sparse:
- $(CC) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 sparse.c -o $@
+ $(LDMINFO_CC) -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 sparse.c -o $@

clean:
$(RM) $(OUT) $(OBJ)