Changeset 192 for trunk/src/slib.c
- Timestamp:
- Nov 12, 2008, 12:37:00 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/slib.c
r190 r192 1700 1700 struct stat lbuf; 1701 1701 struct stat buf; 1702 int errval = 0; 1702 1703 int lstat_return; 1703 1704 int stat_return; … … 1750 1751 else 1751 1752 lstat_return = retry_lstat(FIL__, __LINE__, filename, &lbuf); 1753 errval = errno; 1752 1754 #ifdef USE_SUID 1753 1755 if (priv == SL_YESPRIV) … … 1759 1761 lstat_return = ENOENT; 1760 1762 if ( (mode == SL_OPEN_FOR_READ && lstat_return == ENOENT) || 1761 (err no!= ENOENT))1763 (errval != ENOENT)) 1762 1764 { 1763 1765 TPT(( 0, FIL__, __LINE__, _("msg=<lstat: %s> errno=<%d>\n"), 1764 filename, errno)); 1765 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1766 filename, errval)); 1767 errno = errval; 1768 SL_IRETURN(SL_ESTAT, _("sl_open_file")); 1766 1769 } 1767 1770 } … … 1770 1773 ( S_ISDIR(lbuf.st_mode) || (S_IWOTH & lbuf.st_mode) ) 1771 1774 ) 1772 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1773 1775 { 1776 int retval = S_ISDIR(lbuf.st_mode) ? SL_EISDIR : SL_EBADOTH; 1777 errno = 0; 1778 SL_IRETURN(retval, _("sl_open_file")); 1779 } 1774 1780 1775 1781 /* O_NOATIME has an effect for read(). But write() ?. … … 1780 1786 fd = aud_open_noatime (FIL__, __LINE__, priv, filename, 1781 1787 O_RDONLY|O_NONBLOCK, 0, &o_noatime); 1788 errval = errno; 1782 1789 if (fd >= 0) { 1783 1790 sflags = retry_fcntl(FIL__, __LINE__, fd, F_GETFL, 0); … … 1792 1799 fd = aud_open (FIL__, __LINE__, priv, filename, 1793 1800 O_WRONLY, open_mode); 1801 errval = errno; 1794 1802 break; 1795 1803 case SL_OPEN_SAFE_RDWR: 1796 1804 if (lstat_return == ENOENT) 1797 fd = aud_open (FIL__, __LINE__, priv, filename, 1798 O_RDWR|O_CREAT|O_EXCL, open_mode); 1805 { 1806 fd = aud_open (FIL__, __LINE__, priv, filename, 1807 O_RDWR|O_CREAT|O_EXCL, open_mode); 1808 errval = errno; 1809 } 1799 1810 else 1800 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1811 { 1812 errno = errval; 1813 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1814 } 1801 1815 break; 1802 1816 case SL_OPEN_FOR_RDWR: 1803 1817 if (lstat_return == ENOENT) 1804 1805 1818 fd = aud_open (FIL__, __LINE__, priv, filename, 1819 O_RDWR|O_CREAT|O_EXCL, open_mode); 1806 1820 else 1807 1821 fd = aud_open (FIL__, __LINE__, priv, filename, 1808 1822 O_RDWR, open_mode); 1823 errval = errno; 1809 1824 break; 1810 1825 case SL_OPEN_FOR_WTRUNC: … … 1815 1830 fd = aud_open (FIL__, __LINE__, priv, filename, 1816 1831 O_WRONLY|O_TRUNC, open_mode); 1832 errval = errno; 1817 1833 break; 1818 1834 case SL_OPEN_FOR_RWTRUNC: … … 1823 1839 fd = aud_open (FIL__, __LINE__, priv, filename, 1824 1840 O_RDWR|O_TRUNC, open_mode); 1841 errval = errno; 1825 1842 break; 1826 1843 default: 1844 errno = 0; 1827 1845 SL_IRETURN(SL_EINTERNAL, _("sl_open_file")); 1828 1846 } … … 1831 1849 { 1832 1850 TPT(( 0, FIL__, __LINE__, _("msg=<Error opening: %s> errno=<%d>\n"), 1833 filename, errno)); 1851 filename, errval)); 1852 errno = errval; 1834 1853 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1835 1854 } … … 1840 1859 #endif 1841 1860 stat_return = retry_fstat(FIL__, __LINE__, fd, &buf); 1861 errval = errno; 1842 1862 #ifdef USE_SUID 1843 1863 if (priv == SL_YESPRIV) … … 1848 1868 { 1849 1869 close (fd); 1850 SL_IRETURN(SL_EBADFILE, _("sl_open_file")); 1851 } 1870 errno = errval; 1871 SL_IRETURN(SL_EFSTAT, _("sl_open_file")); 1872 } 1873 1874 errno = 0; 1852 1875 1853 1876 if (lstat_return != ENOENT && buf.st_ino != lbuf.st_ino) … … 2221 2244 /* int sflags; */ 2222 2245 int retval; 2246 int error; 2223 2247 2224 2248 int byteread = 0; … … 2280 2304 else 2281 2305 { 2306 error = errno; 2282 2307 if (is_nonblocking == SL_FALSE) 2283 2308 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2284 2309 TPT(( 0, FIL__, __LINE__, _("msg=<read error>"))); 2310 errno = error; 2285 2311 return (SL_EREAD); 2286 2312 } … … 2299 2325 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2300 2326 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2327 errno = 0; 2301 2328 return (SL_TIMEOUT); 2302 2329 } 2303 2330 else 2304 2331 { 2332 error = errno; 2305 2333 if (is_nonblocking == SL_FALSE) 2306 2334 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2307 2335 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2336 errno = error; 2308 2337 return (SL_EREAD); 2309 2338 } … … 2314 2343 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2315 2344 TPT(( 0, FIL__, __LINE__, _("msg=<terminated>"))); 2345 errno = 0; 2316 2346 return (SL_EREAD); 2317 2347 } … … 2325 2355 retry_fcntl(FIL__, __LINE__, fd, F_SETFL, sflags); 2326 2356 TPT(( 0, FIL__, __LINE__, _("msg=<timeout>"))); 2357 errno = 0; 2327 2358 return (SL_TIMEOUT); 2328 2359 } … … 2544 2575 char * sl_error_string(int errorcode) 2545 2576 { 2577 2546 2578 switch (errorcode) 2547 2579 { … … 2579 2611 case SL_EBADOTH: 2580 2612 return _("World writeable."); 2613 case SL_EISDIR: 2614 return _("Is a directory."); 2581 2615 case SL_EBADFILE: 2582 2616 return _("File access error."); … … 2588 2622 case SL_ESTAT: 2589 2623 return _("stat() failed."); 2624 case SL_EFSTAT: 2625 return _("fstat() failed."); 2590 2626 default: 2591 2627 return _("Unknown error.");
Note:
See TracChangeset
for help on using the changeset viewer.