Changeset 2383 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-devices.c
- Timestamp:
- Sep 10, 2009, 2:55:51 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2382 r2383 525 525 if (tmp1) { 526 526 mr_asprintf(command, "%s -scanbus 2> /dev/null | tr -s '\t' ' ' | grep \"[0-9]*,[0-9]*,[0-9]*\" | grep -v \"[0-9]*) \\*\" | grep CD | cut -d' ' -f2 | head -n1", cdr_exe); 527 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));527 tmp = call_program_and_get_last_line_of_output(command); 528 528 mr_free(command); 529 529 } … … 805 805 806 806 log_msg(1, "command=%s", command); 807 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));807 tmp = call_program_and_get_last_line_of_output(command); 808 808 mr_free(command); 809 809 … … 833 833 } 834 834 835 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1"));835 tmp = call_program_and_get_last_line_of_output("dvdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1"); 836 836 log_msg(5, "tmp = '%s'", tmp); 837 837 if (!tmp[0]) 838 838 mr_free(tmp); 839 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output ("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1") 840 ); 839 tmp = call_program_and_get_last_line_of_output("cdrecord -scanbus 2> /dev/null | grep \") '\" | grep -n \"\" | grep DVD | cut -d':' -f1"); 841 840 if (tmp[0]) { 842 841 devno = atoi(tmp) - 1; … … 1097 1096 char *mddevice = (char *) malloc(32); 1098 1097 char command[MAX_STR_LEN]; 1098 char *tmp = NULL; 1099 1099 int vndev = 2; 1100 if (atoi 1101 (call_program_and_get_last_line_of_output 1102 ("/sbin/sysctl -n kern.osreldate")) < 500000) { 1100 int i = 2; 1101 1102 tmp = call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")); 1103 i = atoi(tmp); 1104 mr_free(tmp); 1105 1106 if (i < 500000) { 1103 1107 do { 1104 1108 sprintf(mddevice, "vn%ic", vndev++); … … 1133 1137 { 1134 1138 char *command = NULL; 1139 char *tmp = NULL; 1135 1140 int res = 0; 1141 int i = 0; 1136 1142 1137 1143 if (strncmp(dname, "/dev/", 5) == 0) { … … 1139 1145 } 1140 1146 1141 if (atoi 1142 (call_program_and_get_last_line_of_output 1143 ("/sbin/sysctl -n kern.osreldate")) < 500000) { 1147 tmp = call_program_and_get_last_line_of_output("/sbin/sysctl -n kern.osreldate")); 1148 i = atoi(tmp); 1149 mr_free(tmp); 1150 1151 if (i < 500000) { 1144 1152 mr_asprintf(command, "vnconfig -d %s", dname); 1145 1153 } else { … … 1653 1661 /* Initiate bkpinfo netfs_mount path from running environment if not already done */ 1654 1662 if (bkpinfo->netfs_mount == NULL) { 1655 mr_asprintf(bkpinfo->netfs_mount, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"));1663 bkpinfo->netfs_mount = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"); 1656 1664 } 1657 1665 #ifdef __FreeBSD__ … … 1682 1690 mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", bkpinfo->netfs_mount); 1683 1691 mr_free(bkpinfo->isodir); 1684 mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(command));1692 bkpinfo->isodir = call_program_and_get_last_line_of_output(command); 1685 1693 mr_free(command); 1686 1694 … … 1722 1730 mr_free(bkpinfo->isodir); 1723 1731 if (is_this_device_mounted(bkpinfo->netfs_mount)) { 1724 mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"));1732 bkpinfo->isodir = call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1"); 1725 1733 1726 1734 } else { … … 1827 1835 #ifdef __FreeBSD__ 1828 1836 #define EXAMPLEBD "/dev/ad0" 1829 mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));1837 bkpinfo->boot_device = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"); 1830 1838 #else 1831 1839 #define EXAMPLEBD "/dev/hda" 1832 mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));1840 bkpinfo->boot_device = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"); 1833 1841 #endif 1834 1842 i = which_boot_loader(bkpinfo->boot_device); … … 1887 1895 mr_free(tmp); 1888 1896 // NTFS 1889 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"));1897 tmp = call_program_and_get_last_line_of_output("parted2fdisk -l | grep -i ntfs | awk '{ print $1};' | tr -s '\\n' ' ' | awk '{ print $0};'"); 1890 1898 if (strlen(tmp) > 2) { 1891 1899 p = popup_and_get_string("NTFS partitions", "Please enter/confirm the NTFS partitions you wish to backup as well.", tmp); … … 2030 2038 2031 2039 mr_asprintf(exclude_these_directories,"%s",list_of_NETFS_mounts_only()); 2032 mr_asprintf(exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|sshfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));2040 exclude_these_devices = call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|sshfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"); 2033 2041 snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices); 2034 2042 mr_free(exclude_these_devices); … … 2051 2059 static char result_sz[512]; 2052 2060 2053 mr_asprintf(exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));2061 exclude_these_directories = call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"); 2054 2062 snprintf(result_sz, 511, "%s", exclude_these_directories); 2055 2063 mr_free(exclude_these_directories); … … 2103 2111 2104 2112 #ifdef __FreeBSD__ 2105 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));2113 tmp = call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"); 2106 2114 #else 2107 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x fuse.sshfs -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));2115 tmp = call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x fuse.sshfs -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"); 2108 2116 #endif 2109 2117 … … 2199 2207 if (g_ISO_restore_mode) { 2200 2208 mr_asprintf(tmp, "mount | grep iso9660 | awk '{print $3;}'"); 2201 mr_asprintf(mountdev, "%s%s", call_program_and_get_last_line_of_output(tmp), "/archives/THIS-CD-NUMBER"); 2209 mountdev = call_program_and_get_last_line_of_output(tmp); 2210 mr_strcat(mountdev, "/archives/THIS-CD-NUMBER"); 2202 2211 mr_free(tmp); 2203 2212 … … 2252 2261 2253 2262 #ifdef __FreeBSD__ 2254 mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1"));2263 output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1"); 2255 2264 #else 2256 mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | sed 's/[0-9]//' | sed 's/[0-9]//'"));2265 output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | sed 's/[0-9]//' | sed 's/[0-9]//'"); 2257 2266 if (strstr(output, "/dev/cciss/")) { 2258 2267 mr_free(output); 2259 mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | cut -dp -f1"));2268 output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1 | cut -dp -f1"); 2260 2269 } 2261 2270 if (strstr(output, "/dev/md")) { 2262 2271 mr_free(output); 2263 mr_asprintf(output, "%s", call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1"));2272 output = call_program_and_get_last_line_of_output("mount | grep ' on / ' | cut -d' ' -f1"); 2264 2273 } 2265 2274 #endif … … 2499 2508 log_msg(1, "curr_fname = %s", curr_fname); 2500 2509 mr_asprintf(command, "file %s", curr_fname); 2501 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));2510 tmp = call_program_and_get_last_line_of_output(command); 2502 2511 mr_free(command); 2503 2512 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; p--); … … 2550 2559 mr_free(fdisk); 2551 2560 2552 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));2561 tmp = call_program_and_get_last_line_of_output(command); 2553 2562 mr_free(command); 2554 2563
Note:
See TracChangeset
for help on using the changeset viewer.