Sophie

Sophie

distrib > Mandriva > 9.0 > i586 > by-pkgid > 2269bb274471fd2722517c2c0b740d7f > files > 108

rpm-devel-4.0.4-19mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>lib/fs.c Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.17 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="modules.html">Modules</a> &nbsp; <a class="qindex" href="annotated.html">Data Structures</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Data Fields</a> &nbsp; <a class="qindex" href="globals.html">Globals</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; </center>
<hr><h1>lib/fs.c</h1><a href="fs_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*@-mods@*/</span>
00006 <span class="preprocessor">#include "<a class="code" href="system_8h.html">system.h</a>"</span>
00007 <span class="preprocessor">#include &lt;<a class="code" href="rpmlib_8h.html">rpmlib.h</a>&gt;</span>
00008 <span class="preprocessor">#include &lt;<a class="code" href="rpmmacro_8h.html">rpmmacro.h</a>&gt;</span>   <span class="comment">/* XXX for rpmGetPath */</span>
00009 <span class="preprocessor">#include "<a class="code" href="debug_8h.html">debug.h</a>"</span>
00010 
00011 <span class="comment">/*@-usereleased -onlytrans@*/</span>
00012 
<a name="l00013"></a><a class="code" href="structfsinfo.html">00013</a> <span class="keyword">struct </span><a class="code" href="structfsinfo.html">fsinfo</a> {
<a name="l00014"></a><a class="code" href="structfsinfo.html#m0">00014</a> <span class="comment">/*@only@*/</span> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="structfsinfo.html#m0">mntPoint</a>;       
<a name="l00015"></a><a class="code" href="structfsinfo.html#m1">00015</a>     dev_t <a class="code" href="structfsinfo.html#m1">dev</a>;                          
<a name="l00016"></a><a class="code" href="structfsinfo.html#m2">00016</a>     <span class="keywordtype">int</span> <a class="code" href="structfsinfo.html#m2">rdonly</a>;                         
00017 };
00018 
00019 <span class="comment">/*@unchecked@*/</span>
<a name="l00020"></a><a class="code" href="fs_8c.html#a0">00020</a> <span class="comment">/*@only@*/</span> <span class="comment">/*@null@*/</span> <span class="keyword">static</span> <span class="keyword">struct </span><a class="code" href="structfsinfo.html">fsinfo</a> * filesystems = NULL;
00021 <span class="comment">/*@unchecked@*/</span>
<a name="l00022"></a><a class="code" href="fs_8c.html#a1">00022</a> <span class="comment">/*@only@*/</span> <span class="comment">/*@null@*/</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> ** <a class="code" href="fs_8c.html#a1">fsnames</a> = NULL;
00023 <span class="comment">/*@unchecked@*/</span>
<a name="l00024"></a><a class="code" href="fs_8c.html#a2">00024</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="fs_8c.html#a2">numFilesystems</a> = 0;
00025 
<a name="l00026"></a><a class="code" href="fs_8c.html#a3">00026</a> <span class="keywordtype">void</span> <a class="code" href="fs_8c.html#a3">freeFilesystems</a>(<span class="keywordtype">void</span>)
00027 {
00028     <span class="keywordflow">if</span> (filesystems) {
00029         <span class="keywordtype">int</span> i;
00030         <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="fs_8c.html#a2">numFilesystems</a>; i++)
00031             filesystems[i].<a class="code" href="structfsinfo.html#m0">mntPoint</a> = <a class="code" href="poptint_8h.html#a14">_free</a>(filesystems[i].mntPoint);
00032         filesystems = <a class="code" href="poptint_8h.html#a14">_free</a>(filesystems);
00033     }
00034     <span class="keywordflow">if</span> (fsnames) {
00035 <span class="preprocessor">#if 0   </span><span class="comment">/* XXX leak/segfault on exit of "rpm -qp --qf '%{#fsnames}' pkg" */</span>
00036         free(<a class="code" href="fs_8c.html#a1">fsnames</a>);
00037 <span class="preprocessor">#endif</span>
00038 <span class="preprocessor"></span>        <a class="code" href="fs_8c.html#a1">fsnames</a> = NULL;
00039     }
00040     <a class="code" href="fs_8c.html#a2">numFilesystems</a> = 0;
00041 }
00042 
00043 <span class="preprocessor">#if HAVE_MNTCTL</span>
00044 <span class="preprocessor"></span>
00045 <span class="comment">/* modeled after sample code from Till Bubeck */</span>
00046 
00047 <span class="preprocessor">#include &lt;sys/mntctl.h&gt;</span>
00048 <span class="preprocessor">#include &lt;sys/vmount.h&gt;</span>
00049 
00050 <span class="comment">/* </span>
00051 <span class="comment"> * There is NO mntctl prototype in any header file of AIX 3.2.5! </span>
00052 <span class="comment"> * So we have to declare it by ourself...</span>
00053 <span class="comment"> */</span>
00054 <span class="keywordtype">int</span> mntctl(<span class="keywordtype">int</span> command, <span class="keywordtype">int</span> size, <span class="keywordtype">char</span> *buffer);
00055 
00061 <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="fs_8c.html#a4">getFilesystemList</a>(<span class="keywordtype">void</span>)
00062         <span class="comment">/*@*/</span>
00063 {
00064     <span class="keywordtype">int</span> size;
00065     <span class="keywordtype">void</span> * buf;
00066     <span class="keyword">struct </span>vmount * vm;
00067     <span class="keyword">struct </span>stat sb;
00068     <span class="keywordtype">int</span> rdonly = 0;
00069     <span class="keywordtype">int</span> num;
00070     <span class="keywordtype">int</span> fsnameLength;
00071     <span class="keywordtype">int</span> i;
00072 
00073     num = mntctl(MCTL_QUERY, <span class="keyword">sizeof</span>(size), (<span class="keywordtype">char</span> *) &amp;size);
00074     <span class="keywordflow">if</span> (num &lt; 0) {
00075         <a class="code" href="rpmerr_8h.html#a5">rpmError</a>(<a class="code" href="rpmerr_8h.html#a91a42">RPMERR_MTAB</a>, <a class="code" href="system_8h.html#a18">_</a>(<span class="stringliteral">"mntctl() failed to return size: %s\n"</span>), 
00076                  <a class="code" href="popt_8c.html#a1">strerror</a>(<a class="code" href="system_8h.html#a29">errno</a>));
00077         <span class="keywordflow">return</span> 1;
00078     }
00079 
00080     <span class="comment">/*</span>
00081 <span class="comment">     * Double the needed size, so that even when the user mounts a </span>
00082 <span class="comment">     * filesystem between the previous and the next call to mntctl</span>
00083 <span class="comment">     * the buffer still is large enough.</span>
00084 <span class="comment">     */</span>
00085     size *= 2;
00086 
00087     buf = <a class="code" href="system_8h.html#a36">alloca</a>(size);
00088     num = mntctl(MCTL_QUERY, size, buf);
00089     <span class="keywordflow">if</span> ( num &lt;= 0 ) {
00090         <a class="code" href="rpmerr_8h.html#a5">rpmError</a>(<a class="code" href="rpmerr_8h.html#a91a42">RPMERR_MTAB</a>, <a class="code" href="system_8h.html#a18">_</a>(<span class="stringliteral">"mntctl() failed to return mount points: %s\n"</span>), 
00091                  <a class="code" href="popt_8c.html#a1">strerror</a>(<a class="code" href="system_8h.html#a29">errno</a>));
00092         <span class="keywordflow">return</span> 1;
00093     }
00094 
00095     <a class="code" href="fs_8c.html#a2">numFilesystems</a> = num;
00096 
00097     filesystems = <a class="code" href="rpmmalloc_8c.html#a2">xcalloc</a>((<a class="code" href="fs_8c.html#a2">numFilesystems</a> + 1), <span class="keyword">sizeof</span>(*filesystems));
00098     <a class="code" href="fs_8c.html#a1">fsnames</a> = <a class="code" href="rpmmalloc_8c.html#a2">xcalloc</a>((<a class="code" href="fs_8c.html#a2">numFilesystems</a> + 1), <span class="keyword">sizeof</span>(<span class="keywordtype">char</span> *));
00099     
00100     <span class="keywordflow">for</span> (vm = buf, i = 0; i &lt; num; i++) {
00101         <span class="keywordtype">char</span> *fsn;
00102         fsnameLength = vm-&gt;vmt_data[VMT_STUB].vmt_size;
00103         fsn = <a class="code" href="rpmmalloc_8c.html#a1">xmalloc</a>(fsnameLength + 1);
00104         strncpy(fsn, (<span class="keywordtype">char</span> *)vm + vm-&gt;vmt_data[VMT_STUB].vmt_off, 
00105                 fsnameLength);
00106 
00107         filesystems[i].<a class="code" href="structfsinfo.html#m0">mntPoint</a> = <a class="code" href="fs_8c.html#a1">fsnames</a>[i] = fsn;
00108         
00109         <span class="keywordflow">if</span> (stat(filesystems[i].mntPoint, &amp;sb)) {
00110             <a class="code" href="rpmerr_8h.html#a5">rpmError</a>(<a class="code" href="rpmerr_8h.html#a91a43">RPMERR_STAT</a>, <a class="code" href="system_8h.html#a18">_</a>(<span class="stringliteral">"failed to stat %s: %s\n"</span>), <a class="code" href="fs_8c.html#a1">fsnames</a>[i],
00111                         <a class="code" href="popt_8c.html#a1">strerror</a>(<a class="code" href="system_8h.html#a29">errno</a>));
00112 
00113             <a class="code" href="fs_8c.html#a3">freeFilesystems</a>();
00114             <span class="keywordflow">return</span> 1;
00115         }
00116         
00117         filesystems[i].<a class="code" href="structfsinfo.html#m1">dev</a> = sb.st_dev;
00118         filesystems[i].<a class="code" href="structfsinfo.html#m2">rdonly</a> = rdonly;
00119 
00120         <span class="comment">/* goto the next vmount structure: */</span>
00121         vm = (<span class="keyword">struct </span>vmount *)((char *)vm + vm-&gt;vmt_length);
00122     }
00123 
00124     filesystems[i].<a class="code" href="structfsinfo.html#m0">mntPoint</a> = NULL;
00125     <a class="code" href="fs_8c.html#a1">fsnames</a>[i]              = NULL;
00126 
00127     <span class="keywordflow">return</span> 0;
00128 }
00129 
00130 <span class="preprocessor">#else   </span><span class="comment">/* HAVE_MNTCTL */</span>
00131 
<a name="l00137"></a><a class="code" href="fs_8c.html#a4">00137</a> <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="fs_8c.html#a4">getFilesystemList</a>(<span class="keywordtype">void</span>)
00138         <span class="comment">/*@globals fileSystem, internalState@*/</span>
00139         <span class="comment">/*@modifies fileSystem, internalState@*/</span>
00140 {
00141     <span class="keywordtype">int</span> numAlloced = 10;
00142     <span class="keyword">struct </span>stat sb;
00143     <span class="keywordtype">int</span> i;
00144     <span class="keyword">const</span> <span class="keywordtype">char</span> * mntdir;
00145     <span class="keywordtype">int</span> rdonly = 0;
00146 
00147 <span class="preprocessor">#   if GETMNTENT_ONE || GETMNTENT_TWO</span>
00148 <span class="preprocessor"></span>    <a class="code" href="structour__mntent.html">our_mntent</a> item;
00149     FILE * mtab;
00150 
00151         mtab = fopen(<a class="code" href="system_8h.html#a28">MOUNTED</a>, <span class="stringliteral">"r"</span>);
00152         <span class="keywordflow">if</span> (!mtab) {
00153             <a class="code" href="rpmerr_8h.html#a5">rpmError</a>(<a class="code" href="rpmerr_8h.html#a91a42">RPMERR_MTAB</a>, <a class="code" href="system_8h.html#a18">_</a>(<span class="stringliteral">"failed to open %s: %s\n"</span>), <a class="code" href="system_8h.html#a28">MOUNTED</a>, 
00154                      <a class="code" href="popt_8c.html#a1">strerror</a>(<a class="code" href="system_8h.html#a29">errno</a>));
00155             <span class="keywordflow">return</span> 1;
00156         }
00157 <span class="preprocessor">#   elif HAVE_GETMNTINFO_R</span>
00158 <span class="preprocessor"></span>    <span class="keyword">struct </span>statfs * mounts = NULL;
00159     <span class="keywordtype">int</span> mntCount = 0, bufSize = 0, flags = MNT_NOWAIT;
00160     <span class="keywordtype">int</span> nextMount = 0;
00161 
00162         getmntinfo_r(&amp;mounts, flags, &amp;mntCount, &amp;bufSize);
00163 <span class="preprocessor">#   endif</span>
00164 <span class="preprocessor"></span>
00165     filesystems = <a class="code" href="rpmmalloc_8c.html#a2">xcalloc</a>((numAlloced + 1), <span class="keyword">sizeof</span>(*filesystems));      <span class="comment">/* XXX memory leak */</span>
00166 
00167     <a class="code" href="fs_8c.html#a2">numFilesystems</a> = 0;
00168     <span class="keywordflow">while</span> (1) {
00169 <span class="preprocessor">#       if GETMNTENT_ONE</span>
00170 <span class="preprocessor"></span>            <span class="comment">/* this is Linux */</span>
00171             <span class="comment">/*@-modunconnomods -moduncon @*/</span>
00172             <a class="code" href="structour__mntent.html">our_mntent</a> * itemptr = <a class="code" href="system_8h.html#a44">getmntent</a>(mtab);
00173             <span class="keywordflow">if</span> (!itemptr) <span class="keywordflow">break</span>;
00174             item = *itemptr;    <span class="comment">/* structure assignment */</span>
00175             mntdir = item.<a class="code" href="structour__mntent.html#m0">our_mntdir</a>;
00176 <span class="preprocessor">#if defined(MNTOPT_RO)</span>
00177 <span class="preprocessor"></span>            <span class="comment">/*@-compdef@*/</span>
00178             <span class="keywordflow">if</span> (hasmntopt(itemptr, MNTOPT_RO) != NULL)
00179                 rdonly = 1;
00180             <span class="comment">/*@=compdef@*/</span>
00181 <span class="preprocessor">#endif</span>
00182 <span class="preprocessor"></span>            <span class="comment">/*@=modunconnomods =moduncon @*/</span>
00183 <span class="preprocessor">#       elif GETMNTENT_TWO</span>
00184 <span class="preprocessor"></span>            <span class="comment">/* Solaris, maybe others */</span>
00185             <span class="keywordflow">if</span> (<a class="code" href="system_8h.html#a44">getmntent</a>(mtab, &amp;item)) <span class="keywordflow">break</span>;
00186             mntdir = item.<a class="code" href="structour__mntent.html#m0">our_mntdir</a>;
00187 <span class="preprocessor">#       elif HAVE_GETMNTINFO_R</span>
00188 <span class="preprocessor"></span>            <span class="keywordflow">if</span> (nextMount == mntCount) <span class="keywordflow">break</span>;
00189             mntdir = mounts[nextMount++].f_mntonname;
00190 <span class="preprocessor">#       endif</span>
00191 <span class="preprocessor"></span>
00192         <span class="keywordflow">if</span> (strncmp(mntdir, <span class="stringliteral">"/mnt/"</span>, 5)) {
00193         <span class="keywordflow">if</span> (stat(mntdir, &amp;sb)) {
00194             <a class="code" href="rpmerr_8h.html#a5">rpmError</a>(<a class="code" href="rpmerr_8h.html#a91a43">RPMERR_STAT</a>, <a class="code" href="system_8h.html#a18">_</a>(<span class="stringliteral">"failed to stat %s: %s\n"</span>), mntdir,
00195                         <a class="code" href="popt_8c.html#a1">strerror</a>(<a class="code" href="system_8h.html#a29">errno</a>));
00196 
00197             <a class="code" href="fs_8c.html#a3">freeFilesystems</a>();
00198             <span class="keywordflow">return</span> 1;
00199         }
00200         } <span class="keywordflow">else</span> {
00201           sb.st_dev = 0;
00202         }
00203         
00204         <a class="code" href="fs_8c.html#a2">numFilesystems</a>++;
00205         <span class="keywordflow">if</span> ((<a class="code" href="fs_8c.html#a2">numFilesystems</a> + 1) == numAlloced) {
00206             numAlloced += 10;
00207             filesystems = <a class="code" href="rpmmalloc_8c.html#a3">xrealloc</a>(filesystems, 
00208                                   <span class="keyword">sizeof</span>(*filesystems) * (numAlloced + 1));
00209         }
00210 
00211         filesystems[<a class="code" href="fs_8c.html#a2">numFilesystems</a>-1].dev = sb.st_dev;
00212         filesystems[<a class="code" href="fs_8c.html#a2">numFilesystems</a>-1].mntPoint = <a class="code" href="rpmmalloc_8c.html#a4">xstrdup</a>(mntdir);
00213         filesystems[<a class="code" href="fs_8c.html#a2">numFilesystems</a>-1].rdonly = rdonly;
00214     }
00215 
00216 <span class="preprocessor">#   if GETMNTENT_ONE || GETMNTENT_TWO</span>
00217 <span class="preprocessor"></span>        (void) fclose(mtab);
00218 <span class="preprocessor">#   elif HAVE_GETMNTINFO_R</span>
00219 <span class="preprocessor"></span>        mounts = <a class="code" href="poptint_8h.html#a14">_free</a>(mounts);
00220 <span class="preprocessor">#   endif</span>
00221 <span class="preprocessor"></span>
00222     filesystems[<a class="code" href="fs_8c.html#a2">numFilesystems</a>].dev = 0;
00223     filesystems[<a class="code" href="fs_8c.html#a2">numFilesystems</a>].mntPoint = NULL;
00224     filesystems[<a class="code" href="fs_8c.html#a2">numFilesystems</a>].rdonly = 0;
00225 
00226     <a class="code" href="fs_8c.html#a1">fsnames</a> = <a class="code" href="rpmmalloc_8c.html#a2">xcalloc</a>((<a class="code" href="fs_8c.html#a2">numFilesystems</a> + 1), <span class="keyword">sizeof</span>(*<a class="code" href="fs_8c.html#a1">fsnames</a>));
00227     <span class="keywordflow">for</span> (i = 0; i &lt; <a class="code" href="fs_8c.html#a2">numFilesystems</a>; i++)
00228         <a class="code" href="fs_8c.html#a1">fsnames</a>[i] = filesystems[i].<a class="code" href="structfsinfo.html#m0">mntPoint</a>;
00229     <a class="code" href="fs_8c.html#a1">fsnames</a>[<a class="code" href="fs_8c.html#a2">numFilesystems</a>] = NULL;
00230 
00231     <span class="keywordflow">return</span> 0; 
00232 }
00233 <span class="preprocessor">#endif  </span><span class="comment">/* HAVE_MNTCTL */</span>
00234 
<a name="l00235"></a><a class="code" href="fs_8c.html#a5">00235</a> <span class="keywordtype">int</span> <a class="code" href="fs_8c.html#a5">rpmGetFilesystemList</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *** listptr, <span class="keywordtype">int</span> * num)
00236 {
00237     <span class="keywordflow">if</span> (!<a class="code" href="fs_8c.html#a1">fsnames</a>) 
00238         <span class="keywordflow">if</span> (<a class="code" href="fs_8c.html#a4">getFilesystemList</a>())
00239             <span class="keywordflow">return</span> 1;
00240 
00241     <span class="keywordflow">if</span> (listptr) *listptr = <a class="code" href="fs_8c.html#a1">fsnames</a>;
00242     <span class="keywordflow">if</span> (num) *num = <a class="code" href="fs_8c.html#a2">numFilesystems</a>;
00243 
00244     <span class="keywordflow">return</span> 0;
00245 }
00246 
<a name="l00247"></a><a class="code" href="fs_8c.html#a6">00247</a> <span class="keywordtype">int</span> <a class="code" href="fs_8c.html#a6">rpmGetFilesystemUsage</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> ** fileList, <a class="code" href="header_8h.html#a9">int_32</a> * fssizes, <span class="keywordtype">int</span> numFiles,
00248                           <a class="code" href="header_8h.html#a12">uint_32</a> ** usagesPtr, <span class="comment">/*@unused@*/</span> <span class="keywordtype">int</span> flags)
00249 {
00250     <a class="code" href="header_8h.html#a9">int_32</a> * usages;
00251     <span class="keywordtype">int</span> i, len, j;
00252     <span class="keywordtype">char</span> * buf, * dirName;
00253     <span class="keywordtype">char</span> * chptr;
00254     <span class="keywordtype">int</span> maxLen;
00255     <span class="keywordtype">char</span> * lastDir;
00256     <span class="keyword">const</span> <span class="keywordtype">char</span> * sourceDir;
00257     <span class="keywordtype">int</span> lastfs = 0;
00258     <span class="keywordtype">int</span> lastDev = -1;           <span class="comment">/* I hope nobody uses -1 for a st_dev */</span>
00259     <span class="keyword">struct </span>stat sb;
00260 
00261     <span class="keywordflow">if</span> (!<a class="code" href="fs_8c.html#a1">fsnames</a>) 
00262         <span class="keywordflow">if</span> (<a class="code" href="fs_8c.html#a4">getFilesystemList</a>())
00263             <span class="keywordflow">return</span> 1;
00264 
00265     usages = <a class="code" href="rpmmalloc_8c.html#a2">xcalloc</a>(<a class="code" href="fs_8c.html#a2">numFilesystems</a>, <span class="keyword">sizeof</span>(usages));
00266 
00267     sourceDir = <a class="code" href="macro_8c.html#a53">rpmGetPath</a>(<span class="stringliteral">"%{_sourcedir}"</span>, NULL);
00268 
00269     maxLen = strlen(sourceDir);
00270     <span class="keywordflow">for</span> (i = 0; i &lt; numFiles; i++) {
00271         len = strlen(fileList[i]);
00272         <span class="keywordflow">if</span> (maxLen &lt; len) maxLen = len;
00273     }
00274     
00275     buf = <a class="code" href="system_8h.html#a36">alloca</a>(maxLen + 1);
00276     lastDir = <a class="code" href="system_8h.html#a36">alloca</a>(maxLen + 1);
00277     dirName = <a class="code" href="system_8h.html#a36">alloca</a>(maxLen + 1);
00278     *lastDir = <span class="charliteral">'\0'</span>;
00279 
00280     <span class="comment">/* cut off last filename */</span>
00281     <span class="keywordflow">for</span> (i = 0; i &lt; numFiles; i++) {
00282         <span class="keywordflow">if</span> (*fileList[i] == <span class="charliteral">'/'</span>) {
00283             strcpy(buf, fileList[i]);
00284             chptr = buf + strlen(buf) - 1;
00285             <span class="keywordflow">while</span> (*chptr != <span class="charliteral">'/'</span>) chptr--;
00286             <span class="keywordflow">if</span> (chptr == buf)
00287                 buf[1] = <span class="charliteral">'\0'</span>;
00288             <span class="keywordflow">else</span>
00289                 *chptr-- = <span class="charliteral">'\0'</span>;
00290         } <span class="keywordflow">else</span> {
00291             <span class="comment">/* this should only happen for source packages (gulp) */</span>
00292             strcpy(buf,  sourceDir);
00293         }
00294 
00295         <span class="keywordflow">if</span> (strcmp(lastDir, buf)) {
00296             strcpy(dirName, buf);
00297             chptr = dirName + strlen(dirName) - 1;
00298             <span class="keywordflow">while</span> (stat(dirName, &amp;sb)) {
00299                 <span class="keywordflow">if</span> (<a class="code" href="system_8h.html#a29">errno</a> != ENOENT) {
00300                     <a class="code" href="rpmerr_8h.html#a5">rpmError</a>(<a class="code" href="rpmerr_8h.html#a91a43">RPMERR_STAT</a>, <a class="code" href="system_8h.html#a18">_</a>(<span class="stringliteral">"failed to stat %s: %s\n"</span>), buf,
00301                                 <a class="code" href="popt_8c.html#a1">strerror</a>(<a class="code" href="system_8h.html#a29">errno</a>));
00302                     sourceDir = <a class="code" href="poptint_8h.html#a14">_free</a>(sourceDir);
00303                     usages = <a class="code" href="poptint_8h.html#a14">_free</a>(usages);
00304                     <span class="keywordflow">return</span> 1;
00305                 }
00306 
00307                 <span class="comment">/* cut off last directory part, because it was not found. */</span>
00308                 <span class="keywordflow">while</span> (*chptr != <span class="charliteral">'/'</span>) chptr--;
00309 
00310                 <span class="keywordflow">if</span> (chptr == dirName)
00311                     dirName[1] = <span class="charliteral">'\0'</span>;
00312                 <span class="keywordflow">else</span>
00313                     *chptr-- = <span class="charliteral">'\0'</span>;
00314             }
00315 
00316             <span class="keywordflow">if</span> (lastDev != sb.st_dev) {
00317                 <span class="keywordflow">for</span> (j = 0; j &lt; <a class="code" href="fs_8c.html#a2">numFilesystems</a>; j++)
00318                     <span class="keywordflow">if</span> (filesystems &amp;&amp; filesystems[j].<a class="code" href="structfsinfo.html#m1">dev</a> == sb.st_dev)
00319                         <span class="comment">/*@innerbreak@*/</span> <span class="keywordflow">break</span>;
00320 
00321                 <span class="keywordflow">if</span> (j == <a class="code" href="fs_8c.html#a2">numFilesystems</a>) {
00322                     <a class="code" href="rpmerr_8h.html#a5">rpmError</a>(<a class="code" href="rpmerr_8h.html#a91a44">RPMERR_BADDEV</a>, 
00323                                 <a class="code" href="system_8h.html#a18">_</a>(<span class="stringliteral">"file %s is on an unknown device\n"</span>), buf);
00324                     sourceDir = <a class="code" href="poptint_8h.html#a14">_free</a>(sourceDir);
00325                     usages = <a class="code" href="poptint_8h.html#a14">_free</a>(usages);
00326                     <span class="keywordflow">return</span> 1;
00327                 }
00328 
00329                 lastfs = j;
00330                 lastDev = sb.st_dev;
00331             }
00332         }
00333 
00334         strcpy(lastDir, buf);
00335         usages[lastfs] += fssizes[i];
00336     }
00337 
00338     sourceDir = <a class="code" href="poptint_8h.html#a14">_free</a>(sourceDir);
00339 
00340     <span class="comment">/*@-branchstate@*/</span>
00341     <span class="keywordflow">if</span> (usagesPtr)
00342         *usagesPtr = usages;
00343     <span class="keywordflow">else</span>
00344         usages = <a class="code" href="poptint_8h.html#a14">_free</a>(usages);
00345     <span class="comment">/*@=branchstate@*/</span>
00346 
00347     <span class="keywordflow">return</span> 0;
00348 }
00349 <span class="comment">/*@=usereleased =onlytrans@*/</span>
00350 <span class="comment">/*@=mods@*/</span>
</pre></div><hr><address style="align: right;"><small>Generated on Thu Sep 12 22:14:56 2002 for rpm by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.17 </small></address>
</body>
</html>