[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a question on du.c and df.c rather than a statement of a bug
From: |
Eric Blake |
Subject: |
Re: a question on du.c and df.c rather than a statement of a bug |
Date: |
Wed, 14 Mar 2007 12:58:12 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.4.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Please keep replies on the list.
According to )\(@sS on 3/14/2007 9:54 AM:
> thank you
> for your quick reply. no the application is not planned to be
> distributed. it is just a memory management routine that will be
> deleting files from a folder once a certain space is exceeded. it will
> be integrated in an embedded system. which will be used for research
> purposes within the university.
>
> im trying to use directly df and du because the scope is to make a
> controller, not a memory managing module. i just wanted to extract the
> output directly from du "as is". the question is if you can easily
> identify some pitfalls in using the 2 sources in parallel.
>
> i will look into coreutils. however since the 2 applications where
> designed separately as you say i feel the problems will persist.
>
> basically i have generated files foldersize.c and diskspace.c (which i
> #include from my code) that prepare the option with which the du.o and
> df.o respectively will be called:
>
> foldersize.c_______________________________________
>
> #include <stdio.h>
> #include <stdlib.h>
> ///#if HAVE_INTTYPES_H/
> # include <inttypes.h>
> ///#endif/
>
> #include <stdio.h>
> #include <getopt.h>
> #include <sys/types.h>
> #include <assert.h>
>
> ///void exit(int status);/
> ///using namespace std;/
>
> unsigned long tot_size =0;// variable is declared here and declared as extern
> in du.c
>
> unsigned long getFolderSize(char *path) {
>
> unsigned long folder_size =0;
> char **koko = malloc(*sizeof*(char*) * 30);
> koko[0] = "du";
> koko[1] = "-s";
> koko[2] = path;
> ///printf("path = %s\n",koko[2]);/
> ///du_proc (3, koko);/
> tot_size = 1;
> folder_size = tot_size ;
> printf ("=> %d\n",tot_size);
> *return* (folder_size);
> ///exit(0);/
> }
>
>
> diskspace.c_______________________________________
>
> #include "diskspace.h"
> #include <stdio.h>
> #include <stdlib.h>
> double pct = -1;
> int foo=0;
> unsigned long available;//declared here and as extern in df.c
> ///void exit(int status);/
>
> unsigned long int getDiskSpace()
> {
> unsigned long int available_MB=0;
>
> char *temp=(char*)malloc(10);
> char **koko = &temp;
> koko[0] = "";
> koko[1] = MY_DISK;//MY_DISK is #defined as "/dev/nand" in diskspace.h
>
> df (2, koko);
> available_MB = (available*);
>
> *return* (available_MB);
>
> }
If you expect help debugging your code, post code that will compile, not
pseudocode. Otherwise, I repeat my claim that you are probably the best
person to debug this.
>
>
> to generate df.o and du.o i used the gcc call "as is" from the Makefile
> that came with the package, but i only did the compiling step - not the
> linking.
>
> then i compile my code
>
> <compiling files>
>
>
> *gcc* -c -g diskspace.c -o diskspace.o
> *gcc* -c -g foldersize.c -o foldersize.o
>
> <compiling some more files>
>
> then i link as
>
> g++ -g <object files> df.o du.o diskspace.o foldersize.o <more object files>
> -o controller -I. -L. -lrt -lfetish
>
>
> .
> Thank you for your help
> nass
>
>
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFF+EXE84KuGfSFAYARApEtAKDUbx7RrNzhrmIOfs4lRhQyRxbicgCgta6P
pzZmQWxb9zzxT7858A3PN2s=
=wLat
-----END PGP SIGNATURE-----