Lines 2-8
Link Here
|
2 |
main.cpp - description |
2 |
main.cpp - description |
3 |
------------------- |
3 |
------------------- |
4 |
begin : lun mai 22 18:04:54 CEST 2000 |
4 |
begin : lun mai 22 18:04:54 CEST 2000 |
5 |
copyright : (C) 2000 by François Dupoux |
5 |
copyright : (C) 2000, 2007 by François Dupoux |
6 |
email : fdupoux@partimage.org |
6 |
email : fdupoux@partimage.org |
7 |
***************************************************************************/ |
7 |
***************************************************************************/ |
8 |
// $Revision: 1.70 $ |
8 |
// $Revision: 1.70 $ |
Lines 103-108
static struct option const long_options[
Link Here
|
103 |
}; |
103 |
}; |
104 |
#endif |
104 |
#endif |
105 |
|
105 |
|
|
|
106 |
static char finish_last_countfile_lock[]="/tmp/partimageXXXXXX.lock"; |
107 |
static char finish_last_countfile[]="/tmp/partimageXXXXXX"; |
106 |
static char optstring[]="z:oV:ecmdhf:s:p:bwg:vynSMa:iU:P:XB:"; |
108 |
static char optstring[]="z:oV:ecmdhf:s:p:bwg:vynSMa:iU:P:XB:"; |
107 |
FILE * g_fDebug; // debug file |
109 |
FILE * g_fDebug; // debug file |
108 |
FILE * g_fLocalDebug; // debug file |
110 |
FILE * g_fLocalDebug; // debug file |
Lines 768-774
int main(int argc, char *argv[])
Link Here
|
768 |
|
770 |
|
769 |
nRetries = 5; |
771 |
nRetries = 5; |
770 |
do { |
772 |
do { |
771 |
nLockFile = open(FINISH_LAST_COUNTFILE_LOCK, O_CREAT|O_EXCL, |
773 |
if (mkstemp(finish_last_countfile_lock) == -1) |
|
|
774 |
{ |
775 |
delete g_interface; |
776 |
fprintf(stderr, i18n("Error: Cannot create lock for countfile")); |
777 |
return EXIT_SUCCESS; |
778 |
} |
779 |
nLockFile = open(finish_last_countfile_lock, O_CREAT|O_EXCL, |
772 |
O_RDONLY); |
780 |
O_RDONLY); |
773 |
if (nLockFile == -1) |
781 |
if (nLockFile == -1) |
774 |
{ |
782 |
{ |
Lines 782-788
int main(int argc, char *argv[])
Link Here
|
782 |
fprintf(stderr, i18n("Error: Cannot count remaining partimages")); |
790 |
fprintf(stderr, i18n("Error: Cannot count remaining partimages")); |
783 |
return EXIT_SUCCESS; |
791 |
return EXIT_SUCCESS; |
784 |
} |
792 |
} |
785 |
nCountFile = fopen(FINISH_LAST_COUNTFILE, "r"); |
793 |
if (mkstemp(finish_last_countfile) == -1) |
|
|
794 |
{ |
795 |
delete g_interface; |
796 |
fprintf(stderr, i18n("Error: Cannot create countfile")); |
797 |
return EXIT_SUCCESS; |
798 |
} |
799 |
nCountFile = fopen(finish_last_countfile, "r"); |
786 |
if (nCountFile == NULL) |
800 |
if (nCountFile == NULL) |
787 |
{ |
801 |
{ |
788 |
delete g_interface; |
802 |
delete g_interface; |
Lines 796-803
int main(int argc, char *argv[])
Link Here
|
796 |
delete g_interface; |
810 |
delete g_interface; |
797 |
fclose(nCountFile); |
811 |
fclose(nCountFile); |
798 |
close(nLockFile); |
812 |
close(nLockFile); |
799 |
unlink(FINISH_LAST_COUNTFILE_LOCK); |
813 |
unlink(finish_last_countfile_lock); |
800 |
unlink(FINISH_LAST_COUNTFILE); |
814 |
unlink(finish_last_countfile); |
801 |
// nRes = system("/sbin/shutdown -r now"); |
815 |
// nRes = system("/sbin/shutdown -r now"); |
802 |
// nRes = system("/sbin/reboot"); |
816 |
// nRes = system("/sbin/reboot"); |
803 |
// if we reach this point, it's because shutdown failed |
817 |
// if we reach this point, it's because shutdown failed |
Lines 808-814
int main(int argc, char *argv[])
Link Here
|
808 |
{ |
822 |
{ |
809 |
--nValue; |
823 |
--nValue; |
810 |
fclose(nCountFile); |
824 |
fclose(nCountFile); |
811 |
nCountFile = fopen(FINISH_LAST_COUNTFILE, "w"); |
825 |
nCountFile = fopen(finish_last_countfile, "w"); |
812 |
if (nCountFile == NULL) |
826 |
if (nCountFile == NULL) |
813 |
{ |
827 |
{ |
814 |
delete g_interface; |
828 |
delete g_interface; |
Lines 819-825
int main(int argc, char *argv[])
Link Here
|
819 |
fprintf(nCountFile, "%d\n", nValue); |
833 |
fprintf(nCountFile, "%d\n", nValue); |
820 |
fclose(nCountFile); |
834 |
fclose(nCountFile); |
821 |
close(nLockFile); |
835 |
close(nLockFile); |
822 |
unlink(FINISH_LAST_COUNTFILE_LOCK); |
836 |
unlink(finish_last_countfile_lock); |
823 |
delete g_interface; |
837 |
delete g_interface; |
824 |
return EXIT_SUCCESS; |
838 |
return EXIT_SUCCESS; |
825 |
} |
839 |
} |