branch | jv |
changeset 18053 | e0683b878c4c |
parent 18052 | 47b429933e0e |
parent 15153 | 445368176cf3 |
child 18054 | 56594a8c6b83 |
18052:47b429933e0e | 18053:e0683b878c4c |
---|---|
10 hereby transferred. |
10 hereby transferred. |
11 " |
11 " |
12 "{ Package: 'stx:libbasic' }" |
12 "{ Package: 'stx:libbasic' }" |
13 |
13 |
14 AbstractOperatingSystem subclass:#UnixOperatingSystem |
14 AbstractOperatingSystem subclass:#UnixOperatingSystem |
15 instanceVariableNames: '' |
15 instanceVariableNames:'' |
16 classVariableNames: 'HostName DomainName SlowFork ForkFailed CurrentDirectory |
16 classVariableNames:'HostName DomainName SlowFork ForkFailed CurrentDirectory |
17 LastTimeInfo LastTimeInfoSeconds LastTimeInfoMilliseconds |
17 LastTimeInfo LastTimeInfoSeconds LastTimeInfoMilliseconds |
18 LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp |
18 LastTimeInfoIsLocal CachedMountPoints CacheMountPointsTimeStamp |
19 Codeset CodesetEncoder' |
19 Codeset CodesetEncoder' |
20 poolDictionaries: '' |
20 poolDictionaries:'' |
21 category: 'OS-Unix' |
21 category:'OS-Unix' |
22 ! |
22 ! |
23 |
23 |
24 Object subclass:#FileDescriptorHandle |
24 Object subclass:#FileDescriptorHandle |
25 instanceVariableNames: 'fd' |
25 instanceVariableNames:'fd' |
26 classVariableNames: 'OpenFiles' |
26 classVariableNames:'OpenFiles' |
27 poolDictionaries: '' |
27 poolDictionaries:'' |
28 privateIn: UnixOperatingSystem |
28 privateIn:UnixOperatingSystem |
29 ! |
29 ! |
30 |
30 |
31 OSFileHandle subclass:#FilePointerHandle |
31 OSFileHandle subclass:#FilePointerHandle |
32 instanceVariableNames: '' |
32 instanceVariableNames:'' |
33 classVariableNames: '' |
33 classVariableNames:'' |
34 poolDictionaries: '' |
34 poolDictionaries:'' |
35 privateIn: UnixOperatingSystem |
35 privateIn:UnixOperatingSystem |
36 ! |
36 ! |
37 |
37 |
38 Object subclass:#FileStatusInfo |
38 Object subclass:#FileStatusInfo |
39 instanceVariableNames: 'type mode uid gid size id accessed modified statusChanged path |
39 instanceVariableNames:'type mode uid gid size id accessed modified statusChanged path |
40 numLinks' |
40 numLinks' |
41 classVariableNames: '' |
41 classVariableNames:'' |
42 poolDictionaries: '' |
42 poolDictionaries:'' |
43 privateIn: UnixOperatingSystem |
43 privateIn:UnixOperatingSystem |
44 ! |
44 ! |
45 |
45 |
46 Object subclass:#MountInfo |
46 Object subclass:#MountInfo |
47 instanceVariableNames: 'mountPointPath deviceOrRemotePath fsType attributeString' |
47 instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString' |
48 classVariableNames: '' |
48 classVariableNames:'' |
49 poolDictionaries: '' |
49 poolDictionaries:'' |
50 privateIn: UnixOperatingSystem |
50 privateIn:UnixOperatingSystem |
51 ! |
51 ! |
52 |
52 |
53 Object subclass:#OSProcessStatus |
53 Object subclass:#OSProcessStatus |
54 instanceVariableNames: 'pid status code core' |
54 instanceVariableNames:'pid status code core' |
55 classVariableNames: '' |
55 classVariableNames:'' |
56 poolDictionaries: '' |
56 poolDictionaries:'' |
57 privateIn: UnixOperatingSystem |
57 privateIn:UnixOperatingSystem |
58 ! |
58 ! |
59 |
59 |
60 UnixOperatingSystem::FileDescriptorHandle subclass:#SocketHandle |
60 UnixOperatingSystem::FileDescriptorHandle subclass:#SocketHandle |
61 instanceVariableNames: '' |
61 instanceVariableNames:'' |
62 classVariableNames: 'ProtocolCache' |
62 classVariableNames:'ProtocolCache' |
63 poolDictionaries: '' |
63 poolDictionaries:'' |
64 privateIn: UnixOperatingSystem |
64 privateIn:UnixOperatingSystem |
65 ! |
65 ! |
66 |
66 |
67 !UnixOperatingSystem primitiveDefinitions! |
67 !UnixOperatingSystem primitiveDefinitions! |
68 %{ |
68 %{ |
69 #if defined(_AIX) |
69 #if defined(_AIX) |
522 #ifdef USE_H_ERRNO |
522 #ifdef USE_H_ERRNO |
523 # ifndef h_errno |
523 # ifndef h_errno |
524 extern h_errno; |
524 extern h_errno; |
525 # endif |
525 # endif |
526 #endif |
526 #endif |
527 |
|
528 %} |
|
529 ! ! |
|
530 |
|
531 !UnixOperatingSystem primitiveFunctions! |
|
532 %{ |
|
533 |
|
534 /* |
|
535 * some systems' system() is broken in that it does not correctly |
|
536 * handle EINTR and returns failure even though it actually succeeded. |
|
537 * (LINUX is one of them) |
|
538 * Here is a fixed version. If you encounter EINTR returns from |
|
539 * UnixOperatingSystem>>executeCommand, you ought to define WANT_SYSTEM |
|
540 * in the xxxIntern.h file to get this fixed version. |
|
541 * |
|
542 * As an added BONUS, this system() enables interrupts while waiting |
|
543 * for the child which enables other threads to continue. |
|
544 * (i.e. it is RT safe) |
|
545 */ |
|
546 |
|
547 #if defined(WANT_SYSTEM) |
|
548 |
|
549 /* # define DPRINTF(x) printf x */ |
|
550 # define DPRINTF(x) /* nothing */ |
|
551 |
|
552 # ifndef _STDDEF_H_INCLUDED_ |
|
553 # include <stddef.h> |
|
554 # define _STDDEF_H_INCLUDED_ |
|
555 # endif |
|
556 |
|
557 # ifndef _STDLIB_H_INCLUDED_ |
|
558 # include <stdlib.h> |
|
559 # define _STDLIB_H_INCLUDED_ |
|
560 # endif |
|
561 |
|
562 # ifndef _UNISTD_H_INCLUDED_ |
|
563 # include <unistd.h> |
|
564 # define _UNISTD_H_INCLUDED_ |
|
565 # endif |
|
566 |
|
567 # ifndef _SYS_WAIT_H_INCLUDED |
|
568 # include <sys/wait.h> |
|
569 # define _SYS_WAIT_H_INCLUDED |
|
570 # endif |
|
571 |
|
572 # ifndef _SIGNAL_H_INCLUDED_ |
|
573 # include <signal.h> |
|
574 # define _SIGNAL_H_INCLUDED_ |
|
575 # endif |
|
576 |
|
577 # ifndef _SYS_TYPES_H_INCLUDED_ |
|
578 # include <sys/types.h> |
|
579 # define _SYS_TYPES_H_INCLUDED_ |
|
580 # endif |
|
581 |
|
582 # if (!defined(HAVE_GNU_LD) && !defined (__ELF__)) || !defined(LINUX) |
|
583 # define __environ environ |
|
584 # if 1 /* !defined(LINUX) */ |
|
585 # define __sigemptyset sigemptyset |
|
586 # define __sigaction sigaction |
|
587 # define __sigaddset sigaddset |
|
588 # define __sigprocmask sigprocmask |
|
589 # define __execve execve |
|
590 # define __wait wait |
|
591 # define __waitpid waitpid |
|
592 # endif /* ! LINUX */ |
|
593 // # ifndef __osx__ |
|
594 extern char **environ; |
|
595 // # endif |
|
596 # endif |
|
597 |
|
598 # define __sigprocmask sigprocmask |
|
599 # define __execve execve |
|
600 |
|
601 # define SHELL_PATH "/bin/sh" /* Path of the shell. */ |
|
602 # define SHELL_NAME "sh" /* Name to give it. */ |
|
603 |
|
604 |
|
605 static int |
|
606 mySystem(line) |
|
607 register CONST char *line; |
|
608 { |
|
609 int status, save; |
|
610 pid_t pid; |
|
611 struct sigaction sa, intr, quit; |
|
612 sigset_t block, omask; |
|
613 |
|
614 if (line == NULL) |
|
615 return -1; |
|
616 |
|
617 sa.sa_handler = SIG_IGN; |
|
618 sa.sa_flags = 0; |
|
619 __sigemptyset (&sa.sa_mask); |
|
620 |
|
621 if (__sigaction (SIGINT, &sa, &intr) < 0) { |
|
622 DPRINTF(("1: errno=%d\n", errno)); |
|
623 return -1; |
|
624 } |
|
625 if (__sigaction (SIGQUIT, &sa, &quit) < 0) { |
|
626 save = errno; |
|
627 (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
628 errno = save; |
|
629 DPRINTF(("2: errno=%d\n", errno)); |
|
630 return -1; |
|
631 } |
|
632 |
|
633 __sigemptyset (&block); |
|
634 __sigaddset (&block, SIGCHLD); |
|
635 save = errno; |
|
636 if (__sigprocmask(SIG_BLOCK, &block, &omask) < 0) { |
|
637 if (errno == ENOSYS) |
|
638 errno = save; |
|
639 else { |
|
640 save = errno; |
|
641 (void) __sigaction(SIGINT, &intr, (struct sigaction *) NULL); |
|
642 (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
643 errno = save; |
|
644 DPRINTF(("3: errno=%d\n", errno)); |
|
645 return -1; |
|
646 } |
|
647 } |
|
648 |
|
649 pid = FORK (); |
|
650 if (pid == (pid_t) 0) { |
|
651 /* Child side. */ |
|
652 CONST char *new_argv[4]; |
|
653 new_argv[0] = SHELL_NAME; |
|
654 new_argv[1] = "-c"; |
|
655 new_argv[2] = line; |
|
656 new_argv[3] = NULL; |
|
657 |
|
658 /* Restore the signals. */ |
|
659 (void) __sigaction (SIGINT, &intr, (struct sigaction *) NULL); |
|
660 (void) __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL); |
|
661 (void) __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL); |
|
662 |
|
663 /* Exec the shell. */ |
|
664 (void) __execve (SHELL_PATH, (char *CONST *) new_argv, __environ); |
|
665 _exit (127); |
|
666 } else { |
|
667 if (pid < (pid_t) 0) { |
|
668 /* The fork failed. */ |
|
669 DPRINTF(("4: errno=%d\n", errno)); |
|
670 status = -1; |
|
671 } else { |
|
672 /* Parent side. */ |
|
673 #ifdef NO_WAITPID |
|
674 pid_t child; |
|
675 |
|
676 do { |
|
677 __BEGIN_INTERRUPTABLE__ |
|
678 child = __wait (&status); |
|
679 __END_INTERRUPTABLE__ |
|
680 if (child < 0 && errno != EINTR) { |
|
681 DPRINTF(("5: errno=%d\n", errno)); |
|
682 status = -1; |
|
683 break; |
|
684 } |
|
685 } while (child != pid); |
|
686 #else |
|
687 pid_t child; |
|
688 |
|
689 /* claus: the original did not care for EINTR here ... */ |
|
690 do { |
|
691 __BEGIN_INTERRUPTABLE__ |
|
692 child = __waitpid (pid, &status, 0); |
|
693 __END_INTERRUPTABLE__ |
|
694 } while ((child != pid) && (errno == EINTR)); |
|
695 if (child != pid) { |
|
696 DPRINTF(("6: errno=%d\n", errno)); |
|
697 status = -1; |
|
698 } |
|
699 #endif /* NO_WAITPID */ |
|
700 } |
|
701 } |
|
702 save = errno; |
|
703 if ((__sigaction (SIGINT, &intr, (struct sigaction *) NULL) |
|
704 | __sigaction (SIGQUIT, &quit, (struct sigaction *) NULL) |
|
705 | __sigprocmask (SIG_SETMASK, &omask, (sigset_t *) NULL)) != 0) { |
|
706 if (errno == ENOSYS) { |
|
707 errno = save; |
|
708 } else { |
|
709 status = -1; |
|
710 DPRINTF(("7: errno=%d\n", errno)); |
|
711 } |
|
712 } |
|
713 |
|
714 return status; |
|
715 } |
|
716 #else |
|
717 # define __wait wait |
|
718 #endif /* WANT_SYSTEM */ |
|
719 |
|
720 |
|
721 /* |
|
722 * some systems do not have realpath(); |
|
723 * the alternative of reading from a 'pwp'-pipe |
|
724 * is way too slow. Here is a realpath for the rest of us. |
|
725 * define WANT_REALPATH in the xxxIntern-file to get it. |
|
726 */ |
|
727 |
|
728 #if defined(HAS_REALPATH) |
|
729 # undef WANT_REALPATH |
|
730 #endif |
|
731 #if !defined(HAS_GETWD) && !defined(HAS_GETCWD) |
|
732 # undef WANT_REALPATH |
|
733 #endif |
|
734 |
|
735 #if defined(WANT_REALPATH) |
|
736 |
|
737 # ifndef NULL |
|
738 # define NULL (char *)0 |
|
739 # endif |
|
740 |
|
741 # define MAX_READLINKS 32 |
|
742 |
|
743 # ifndef MAXPATHLEN |
|
744 # define MAXPATHLEN 1024 |
|
745 # endif |
|
746 |
|
747 static |
|
748 char * |
|
749 realpath(path, resolved_path) |
|
750 char *path; |
|
751 char resolved_path []; |
|
752 { |
|
753 char copy_path[MAXPATHLEN]; |
|
754 char link_path[MAXPATHLEN]; |
|
755 char *new_path = resolved_path; |
|
756 char *max_path; |
|
757 int readlinks = 0; |
|
758 int n; |
|
759 |
|
760 /* Make a copy of the source path since we may need to modify it. */ |
|
761 strcpy(copy_path, path); |
|
762 path = copy_path; |
|
763 max_path = copy_path + MAXPATHLEN - 2; |
|
764 /* If it's a relative pathname use getwd for starters. */ |
|
765 if (*path != '/') { |
|
766 #ifdef HAS_GETCWD |
|
767 new_path = getcwd(new_path, MAXPATHLEN - 1); |
|
768 #else |
|
769 new_path = getwd(new_path); |
|
770 #endif |
|
771 if (new_path == NULL) |
|
772 return(NULL); |
|
773 |
|
774 new_path += strlen(new_path); |
|
775 if (new_path[-1] != '/') |
|
776 *new_path++ = '/'; |
|
777 } |
|
778 else { |
|
779 *new_path++ = '/'; |
|
780 path++; |
|
781 } |
|
782 /* Expand each slash-separated pathname component. */ |
|
783 while (*path != '\0') { |
|
784 /* Ignore stray "/". */ |
|
785 if (*path == '/') { |
|
786 path++; |
|
787 continue; |
|
788 } |
|
789 if (*path == '.') { |
|
790 /* Ignore ".". */ |
|
791 if (path[1] == '\0' || path[1] == '/') { |
|
792 path++; |
|
793 continue; |
|
794 } |
|
795 if (path[1] == '.') { |
|
796 if (path[2] == '\0' || path[2] == '/') { |
|
797 path += 2; |
|
798 /* Ignore ".." at root. */ |
|
799 if (new_path == resolved_path + 1) |
|
800 continue; |
|
801 /* Handle ".." by backing up. */ |
|
802 while ((--new_path)[-1] != '/') |
|
803 ; |
|
804 continue; |
|
805 } |
|
806 } |
|
807 } |
|
808 /* Safely copy the next pathname component. */ |
|
809 while (*path != '\0' && *path != '/') { |
|
810 if (path > max_path) { |
|
811 errno = ENAMETOOLONG; |
|
812 return NULL; |
|
813 } |
|
814 *new_path++ = *path++; |
|
815 } |
|
816 #ifdef S_IFLNK |
|
817 /* Protect against infinite loops. */ |
|
818 if (readlinks++ > MAX_READLINKS) { |
|
819 errno = ELOOP; |
|
820 return NULL; |
|
821 } |
|
822 /* See if latest pathname component is a symlink. */ |
|
823 *new_path = '\0'; |
|
824 n = readlink(resolved_path, link_path, MAXPATHLEN - 1); |
|
825 if (n < 0) { |
|
826 /* EINVAL means the file exists but isn't a symlink. */ |
|
827 if (errno != EINVAL) |
|
828 return NULL; |
|
829 } |
|
830 else { |
|
831 /* Note: readlink doesn't add the null byte. */ |
|
832 link_path[n] = '\0'; |
|
833 if (*link_path == '/') |
|
834 /* Start over for an absolute symlink. */ |
|
835 new_path = resolved_path; |
|
836 else |
|
837 /* Otherwise back up over this component. */ |
|
838 while (*(--new_path) != '/') |
|
839 ; |
|
840 /* Safe sex check. */ |
|
841 if (strlen(path) + n >= MAXPATHLEN) { |
|
842 errno = ENAMETOOLONG; |
|
843 return NULL; |
|
844 } |
|
845 /* Insert symlink contents into path. */ |
|
846 strcat(link_path, path); |
|
847 strcpy(copy_path, link_path); |
|
848 path = copy_path; |
|
849 } |
|
850 #endif /* S_IFLNK */ |
|
851 *new_path++ = '/'; |
|
852 } |
|
853 /* Delete trailing slash but don't whomp a lone slash. */ |
|
854 if (new_path != resolved_path + 1 && new_path[-1] == '/') |
|
855 new_path--; |
|
856 /* Make sure it's null terminated. */ |
|
857 *new_path = '\0'; |
|
858 return resolved_path; |
|
859 } |
|
860 # define HAS_REALPATH |
|
861 #endif /* WANT_REALPATH && not HAS_REALPATH */ |
|
527 |
862 |
528 %} |
863 %} |
529 ! ! |
864 ! ! |
530 |
865 |
531 !UnixOperatingSystem class methodsFor:'documentation'! |
866 !UnixOperatingSystem class methodsFor:'documentation'! |
646 ] |
981 ] |
647 [exBegin] |
982 [exBegin] |
648 " |
983 " |
649 ! ! |
984 ! ! |
650 |
985 |
651 |
|
652 !UnixOperatingSystem class methodsFor:'initialization'! |
986 !UnixOperatingSystem class methodsFor:'initialization'! |
653 |
987 |
654 initialize |
988 initialize |
655 "initialize the class" |
989 "initialize the class" |
656 |
990 |
687 "Created: / 15.6.1996 / 15:22:37 / cg" |
1021 "Created: / 15.6.1996 / 15:22:37 / cg" |
688 "Modified: / 7.1.1997 / 19:36:11 / stefan" |
1022 "Modified: / 7.1.1997 / 19:36:11 / stefan" |
689 "Modified: / 11.12.1998 / 16:22:48 / cg" |
1023 "Modified: / 11.12.1998 / 16:22:48 / cg" |
690 ! ! |
1024 ! ! |
691 |
1025 |
692 |
|
693 !UnixOperatingSystem class methodsFor:'OS signal constants'! |
1026 !UnixOperatingSystem class methodsFor:'OS signal constants'! |
694 |
1027 |
695 sigABRT |
1028 sigABRT |
696 "return the signal number for SIGABRT - 0 if not supported by OS |
1029 "return the signal number for SIGABRT - 0 if not supported by OS |
697 (the numeric value is not the same across unix-systems)" |
1030 (the numeric value is not the same across unix-systems)" |
1418 OperatingSystem signalNamed:#SIGCHLD |
1751 OperatingSystem signalNamed:#SIGCHLD |
1419 OperatingSystem signalNamed:#SIGXFSZ |
1752 OperatingSystem signalNamed:#SIGXFSZ |
1420 OperatingSystem signalNamed:#SIGSOUND |
1753 OperatingSystem signalNamed:#SIGSOUND |
1421 " |
1754 " |
1422 ! ! |
1755 ! ! |
1423 |
|
1424 |
1756 |
1425 !UnixOperatingSystem class methodsFor:'error messages'! |
1757 !UnixOperatingSystem class methodsFor:'error messages'! |
1426 |
1758 |
1427 currentErrorNumber |
1759 currentErrorNumber |
1428 "returns the OS's last error nr (i.e. the value of errno). |
1760 "returns the OS's last error nr (i.e. the value of errno). |
2493 |
2825 |
2494 " |
2826 " |
2495 self errorNumberFor:#EOVERFLOW |
2827 self errorNumberFor:#EOVERFLOW |
2496 " |
2828 " |
2497 ! ! |
2829 ! ! |
2498 |
|
2499 |
2830 |
2500 !UnixOperatingSystem class methodsFor:'executing OS commands-implementation'! |
2831 !UnixOperatingSystem class methodsFor:'executing OS commands-implementation'! |
2501 |
2832 |
2502 exec:aCommandPathArg withArguments:argColl environment:environmentDictionary |
2833 exec:aCommandPathArg withArguments:argColl environment:environmentDictionary |
2503 fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory |
2834 fileDescriptors:fdColl fork:doFork newPgrp:newPgrp inDirectory:aDirectory |
2566 aCommandPath := self encodePath:aCommandPathArg. |
2897 aCommandPath := self encodePath:aCommandPathArg. |
2567 |
2898 |
2568 %{ /* STACK: 16000 */ |
2899 %{ /* STACK: 16000 */ |
2569 char **argv; |
2900 char **argv; |
2570 int nargs, i, id; |
2901 int nargs, i, id; |
2571 OBJ arg; |
2902 OBJ arg; |
2572 #ifdef __osx__ |
2903 #ifdef __osx__ |
2573 char **environ = _NSGetEnviron(); |
2904 char **environ = _NSGetEnviron(); |
2574 #else |
2905 #else |
2575 extern char **environ; |
2906 extern char **environ; |
2576 #endif |
2907 #endif |
2938 "Modified: / 21.3.1997 / 10:04:35 / dq" |
3269 "Modified: / 21.3.1997 / 10:04:35 / dq" |
2939 "Modified: / 15.7.1997 / 16:03:51 / stefan" |
3270 "Modified: / 15.7.1997 / 16:03:51 / stefan" |
2940 "Modified: / 5.6.1998 / 19:03:51 / cg" |
3271 "Modified: / 5.6.1998 / 19:03:51 / cg" |
2941 "Created: / 12.11.1998 / 14:39:20 / cg" |
3272 "Created: / 12.11.1998 / 14:39:20 / cg" |
2942 ! ! |
3273 ! ! |
2943 |
|
2944 |
3274 |
2945 !UnixOperatingSystem class methodsFor:'executing OS commands-queries'! |
3275 !UnixOperatingSystem class methodsFor:'executing OS commands-queries'! |
2946 |
3276 |
2947 commandAndArgsForOSCommand:aCommandString |
3277 commandAndArgsForOSCommand:aCommandString |
2948 "get a shell and shell arguments for command execution" |
3278 "get a shell and shell arguments for command execution" |
3037 " |
3367 " |
3038 |
3368 |
3039 "Modified: / 5.6.1998 / 19:03:32 / cg" |
3369 "Modified: / 5.6.1998 / 19:03:32 / cg" |
3040 ! ! |
3370 ! ! |
3041 |
3371 |
3042 |
|
3043 !UnixOperatingSystem class methodsFor:'file access'! |
3372 !UnixOperatingSystem class methodsFor:'file access'! |
3044 |
3373 |
3045 closeFd:anInteger |
3374 closeFd:anInteger |
3046 "low level close of a filedescriptor" |
3375 "low level close of a filedescriptor" |
3047 |
3376 |
3565 #endif |
3894 #endif |
3566 %}. |
3895 %}. |
3567 ^ self primitiveFailed |
3896 ^ self primitiveFailed |
3568 ! ! |
3897 ! ! |
3569 |
3898 |
3570 |
|
3571 !UnixOperatingSystem class methodsFor:'file access rights'! |
3899 !UnixOperatingSystem class methodsFor:'file access rights'! |
3572 |
3900 |
3573 accessMaskFor:aSymbol |
3901 accessMaskFor:aSymbol |
3574 "return the access bits mask for numbers as returned by |
3902 "return the access bits mask for numbers as returned by |
3575 OperatingSystem>>accessModeOf: |
3903 OperatingSystem>>accessModeOf: |
3707 RETURN ( true ); |
4035 RETURN ( true ); |
3708 } |
4036 } |
3709 %}. |
4037 %}. |
3710 ^ self primitiveFailed |
4038 ^ self primitiveFailed |
3711 ! ! |
4039 ! ! |
3712 |
|
3713 |
4040 |
3714 !UnixOperatingSystem class methodsFor:'file locking'! |
4041 !UnixOperatingSystem class methodsFor:'file locking'! |
3715 |
4042 |
3716 lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked |
4043 lockFD:aFileDescriptor shared:isSharedReadLock blocking:blockIfLocked |
3717 "set a lock on the file represented by aFileDescriptor. |
4044 "set a lock on the file represented by aFileDescriptor. |
3934 #endif |
4261 #endif |
3935 } |
4262 } |
3936 %}. |
4263 %}. |
3937 ^ false |
4264 ^ false |
3938 ! ! |
4265 ! ! |
3939 |
|
3940 |
4266 |
3941 !UnixOperatingSystem class methodsFor:'file queries'! |
4267 !UnixOperatingSystem class methodsFor:'file queries'! |
3942 |
4268 |
3943 caseSensitiveFilenames |
4269 caseSensitiveFilenames |
3944 "return true, if the OS has caseSensitive file naming. |
4270 "return true, if the OS has caseSensitive file naming. |
4447 struct stat buf; |
4773 struct stat buf; |
4448 int ret; |
4774 int ret; |
4449 |
4775 |
4450 if (__isStringLike(encodedPathName)) { |
4776 if (__isStringLike(encodedPathName)) { |
4451 # ifdef TRACE_STAT_CALLS |
4777 # ifdef TRACE_STAT_CALLS |
4452 printf("stat on '%s' for isValidPath\n", __stringVal(encodedPathName)); |
4778 printf("stat on '%s' for isValidPath\n", __stringVal(encodedPathName)); |
4453 # endif |
4779 # endif |
4454 __BEGIN_INTERRUPTABLE__ |
4780 __BEGIN_INTERRUPTABLE__ |
4455 do { |
4781 do { |
4456 ret = stat((char *) __stringVal(encodedPathName), &buf); |
4782 ret = stat((char *) __stringVal(encodedPathName), &buf); |
4457 } while ((ret < 0) && (errno == EINTR)); |
4783 } while ((ret < 0) && (errno == EINTR)); |
4458 __END_INTERRUPTABLE__ |
4784 __END_INTERRUPTABLE__ |
4459 if (ret < 0) { |
4785 if (ret < 0) { |
4460 @global(LastErrorNumber) = __mkSmallInteger(errno); |
4786 @global(LastErrorNumber) = __mkSmallInteger(errno); |
4461 RETURN (false); |
4787 RETURN (false); |
4462 } |
4788 } |
4463 RETURN ( ret ? false : true ); |
4789 RETURN ( ret ? false : true ); |
4464 } |
4790 } |
4465 %}. |
4791 %}. |
4466 ^ self primitiveFailed |
4792 ^ self primitiveFailed |
4467 |
4793 |
4468 "/ alternative: |
4794 "/ alternative: |
5013 ^ '' |
5339 ^ '' |
5014 |
5340 |
5015 "Modified: / 5.6.1998 / 18:38:11 / cg" |
5341 "Modified: / 5.6.1998 / 18:38:11 / cg" |
5016 ! ! |
5342 ! ! |
5017 |
5343 |
5018 |
|
5019 !UnixOperatingSystem class methodsFor:'interrupts & signals'! |
5344 !UnixOperatingSystem class methodsFor:'interrupts & signals'! |
5020 |
5345 |
5021 defaultSignal:signalNumber |
5346 defaultSignal:signalNumber |
5022 "revert to the default action on arrival of a (Unix-)signal. |
5347 "revert to the default action on arrival of a (Unix-)signal. |
5023 Dont confuse Unix signals with smalltalk signals. |
5348 Dont confuse Unix signals with smalltalk signals. |
5713 "Modified: / 28.12.1995 / 15:05:37 / stefan" |
6038 "Modified: / 28.12.1995 / 15:05:37 / stefan" |
5714 "Created: / 23.4.1996 / 16:40:34 / stefan" |
6039 "Created: / 23.4.1996 / 16:40:34 / stefan" |
5715 "Modified: / 27.1.1998 / 20:05:59 / cg" |
6040 "Modified: / 27.1.1998 / 20:05:59 / cg" |
5716 ! ! |
6041 ! ! |
5717 |
6042 |
5718 |
|
5719 !UnixOperatingSystem class methodsFor:'ipc support'! |
6043 !UnixOperatingSystem class methodsFor:'ipc support'! |
5720 |
6044 |
5721 makeBidirectionalPipe |
6045 makeBidirectionalPipe |
5722 "make a socketPair, return array with two filedescriptors on success, |
6046 "make a socketPair, return array with two filedescriptors on success, |
5723 nil on failure. |
6047 nil on failure. |
6015 } |
6339 } |
6016 #endif |
6340 #endif |
6017 %}. |
6341 %}. |
6018 self primitiveFailed |
6342 self primitiveFailed |
6019 ! ! |
6343 ! ! |
6020 |
|
6021 |
6344 |
6022 !UnixOperatingSystem class methodsFor:'misc'! |
6345 !UnixOperatingSystem class methodsFor:'misc'! |
6023 |
6346 |
6024 closeLeftOverFiles |
6347 closeLeftOverFiles |
6025 "a bad bad kludge and workaround for a big bug in the linux |
6348 "a bad bad kludge and workaround for a big bug in the linux |
6096 |
6419 |
6097 SlowFork := aBoolean |
6420 SlowFork := aBoolean |
6098 |
6421 |
6099 "Modified: 22.4.1996 / 13:13:09 / cg" |
6422 "Modified: 22.4.1996 / 13:13:09 / cg" |
6100 ! ! |
6423 ! ! |
6101 |
|
6102 |
6424 |
6103 !UnixOperatingSystem class methodsFor:'os queries'! |
6425 !UnixOperatingSystem class methodsFor:'os queries'! |
6104 |
6426 |
6105 executableFileExtensions |
6427 executableFileExtensions |
6106 "return a collection of extensions for executable program files. |
6428 "return a collection of extensions for executable program files. |
6213 getEnvironment |
6535 getEnvironment |
6214 "answer the whole environment as a Dictionary" |
6536 "answer the whole environment as a Dictionary" |
6215 |
6537 |
6216 |resultArray error dict sz "{ Class: SmallInteger }"| |
6538 |resultArray error dict sz "{ Class: SmallInteger }"| |
6217 |
6539 |
6218 %{ |
6540 %{ |
6219 #ifdef __osx__ |
6541 #ifdef __osx__ |
6220 char **environ = _NSGetEnviron(); |
6542 char **environ = _NSGetEnviron(); |
6221 #else |
6543 #else |
6222 extern char **environ; |
6544 extern char **environ; |
6223 #endif |
6545 #endif |
7009 "return an empty dictionary if proceed from error" |
7331 "return an empty dictionary if proceed from error" |
7010 ^ Dictionary new. |
7332 ^ Dictionary new. |
7011 ]. |
7333 ]. |
7012 |
7334 |
7013 "we prefer OrderedDictionary here, because we want to keep the |
7335 "we prefer OrderedDictionary here, because we want to keep the |
7014 order as defined in the OS. But OrderedDictionary is in libbasic2." |
7336 order as defined in the OS." |
7015 retDictionary := OrderedDictionary ? Dictionary new:noOfIf. |
7337 retDictionary := OrderedDictionary new:noOfIf. |
7016 1 to:noOfIf do:[:cnt| |
7338 1 to:noOfIf do:[:cnt| |
7017 |macAddress| |
7339 |macAddress| |
7018 |
7340 |
7019 macAddress := addressArray at:cnt. |
7341 macAddress := addressArray at:cnt. |
7020 macAddress ~= #[0 0 0 0 0 0] ifTrue:[ |
7342 macAddress ~= #[0 0 0 0 0 0] ifTrue:[ |
8232 OperatingSystem supportsSymbolicLinks |
8554 OperatingSystem supportsSymbolicLinks |
8233 " |
8555 " |
8234 |
8556 |
8235 ! ! |
8557 ! ! |
8236 |
8558 |
8237 |
|
8238 !UnixOperatingSystem class methodsFor:'path queries'! |
8559 !UnixOperatingSystem class methodsFor:'path queries'! |
8239 |
8560 |
8240 decodePath:encodedPathName |
8561 decodePath:encodedPathName |
8241 "decode the pathName as returned by system calls. |
8562 "decode the pathName as returned by system calls. |
8242 E.g. linux system calls return sigle byte strings only, |
8563 E.g. linux system calls return sigle byte strings only, |
8362 ^ OSProcessStatus |
8683 ^ OSProcessStatus |
8363 |
8684 |
8364 "Created: / 12.6.1998 / 16:30:43 / cg" |
8685 "Created: / 12.6.1998 / 16:30:43 / cg" |
8365 ! ! |
8686 ! ! |
8366 |
8687 |
8367 |
|
8368 !UnixOperatingSystem class methodsFor:'shared memory access'! |
8688 !UnixOperatingSystem class methodsFor:'shared memory access'! |
8369 |
8689 |
8370 shmAttach:id address:addr flags:flags |
8690 shmAttach:id address:addr flags:flags |
8371 "low level entry to shmat()-system call. |
8691 "low level entry to shmat()-system call. |
8372 Not supported on all operatingSystems" |
8692 Not supported on all operatingSystems" |
8445 ^ self primitiveFailed |
8765 ^ self primitiveFailed |
8446 |
8766 |
8447 "Modified: 22.4.1996 / 13:14:46 / cg" |
8767 "Modified: 22.4.1996 / 13:14:46 / cg" |
8448 ! ! |
8768 ! ! |
8449 |
8769 |
8450 |
|
8451 !UnixOperatingSystem class methodsFor:'socket creation'! |
8770 !UnixOperatingSystem class methodsFor:'socket creation'! |
8452 |
8771 |
8453 socketAccessor |
8772 socketAccessor |
8454 |
8773 |
8455 ^ SocketHandle |
8774 ^ SocketHandle |
8461 is done. Both arguments must be symbols from one of |
8780 is done. Both arguments must be symbols from one of |
8462 #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp." |
8781 #inet,#unix, #appletalk, #x25 .. and #stream, #datagram, #raw resp." |
8463 |
8782 |
8464 ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg |
8783 ^ SocketHandle new domain:domainArg type:typeArg protocol:protocolArg |
8465 ! ! |
8784 ! ! |
8466 |
|
8467 |
8785 |
8468 !UnixOperatingSystem class methodsFor:'time and date'! |
8786 !UnixOperatingSystem class methodsFor:'time and date'! |
8469 |
8787 |
8470 computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
8788 computeOSTimeFromUTCYear:y month:m day:d hour:h minute:min second:s millisecond:millis |
8471 "return the OS-dependent time for the given time and day. |
8789 "return the OS-dependent time for the given time and day. |
8904 " |
9222 " |
8905 OperatingSystem timeInfoFromSeconds:0 localTime:false |
9223 OperatingSystem timeInfoFromSeconds:0 localTime:false |
8906 OperatingSystem timeInfoFromSeconds:3600 localTime:false |
9224 OperatingSystem timeInfoFromSeconds:3600 localTime:false |
8907 " |
9225 " |
8908 ! ! |
9226 ! ! |
8909 |
|
8910 |
9227 |
8911 !UnixOperatingSystem class methodsFor:'users & groups'! |
9228 !UnixOperatingSystem class methodsFor:'users & groups'! |
8912 |
9229 |
8913 getEffectiveGroupID |
9230 getEffectiveGroupID |
8914 "{ Pragma: +optSpace }" |
9231 "{ Pragma: +optSpace }" |
9276 OperatingSystem userInfoOf:'fooBar' |
9593 OperatingSystem userInfoOf:'fooBar' |
9277 OperatingSystem userInfoOf:(OperatingSystem getUserID) |
9594 OperatingSystem userInfoOf:(OperatingSystem getUserID) |
9278 " |
9595 " |
9279 ! ! |
9596 ! ! |
9280 |
9597 |
9281 |
|
9282 !UnixOperatingSystem class methodsFor:'waiting for events'! |
9598 !UnixOperatingSystem class methodsFor:'waiting for events'! |
9283 |
9599 |
9284 blockingChildProcessWait |
9600 blockingChildProcessWait |
9285 "return true, if childProcessWait: blocks, if no children are ready. |
9601 "return true, if childProcessWait: blocks, if no children are ready. |
9286 On those systems, we must be somewhat careful when looking out for |
9602 On those systems, we must be somewhat careful when looking out for |
9995 fd argument not integer or bad return code |
10311 fd argument not integer or bad return code |
9996 " |
10312 " |
9997 ^ self primitiveFailed |
10313 ^ self primitiveFailed |
9998 ! ! |
10314 ! ! |
9999 |
10315 |
10000 |
|
10001 !UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'! |
10316 !UnixOperatingSystem::FileDescriptorHandle class methodsFor:'change & update'! |
10002 |
10317 |
10003 update:aspect with:argument from:anObject |
10318 update:aspect with:argument from:anObject |
10004 "one of our registered handles has been collected" |
10319 "one of our registered handles has been collected" |
10005 |
10320 |
10015 ]. |
10330 ]. |
10016 |
10331 |
10017 "Created: 30.9.1997 / 12:57:35 / stefan" |
10332 "Created: 30.9.1997 / 12:57:35 / stefan" |
10018 ! ! |
10333 ! ! |
10019 |
10334 |
10020 |
|
10021 !UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'! |
10335 !UnixOperatingSystem::FileDescriptorHandle class methodsFor:'initialization'! |
10022 |
10336 |
10023 initialize |
10337 initialize |
10024 OpenFiles := WeakArray new:10. |
10338 OpenFiles := WeakArray new:10. |
10025 OpenFiles addDependent:self. |
10339 OpenFiles addDependent:self. |
10030 |
10344 |
10031 "Created: 26.9.1997 / 17:15:50 / stefan" |
10345 "Created: 26.9.1997 / 17:15:50 / stefan" |
10032 "Modified: 30.9.1997 / 12:40:55 / stefan" |
10346 "Modified: 30.9.1997 / 12:40:55 / stefan" |
10033 ! ! |
10347 ! ! |
10034 |
10348 |
10035 |
|
10036 !UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'! |
10349 !UnixOperatingSystem::FileDescriptorHandle class methodsFor:'instance creation'! |
10037 |
10350 |
10038 for:aFileDescriptor |
10351 for:aFileDescriptor |
10039 "create an instance of myself for a given fileDescriptor" |
10352 "create an instance of myself for a given fileDescriptor" |
10040 |
10353 |
10041 ^ self new for:aFileDescriptor. |
10354 ^ self new for:aFileDescriptor. |
10042 |
10355 |
10043 "Created: 30.9.1997 / 14:00:00 / stefan" |
10356 "Created: 30.9.1997 / 14:00:00 / stefan" |
10044 ! ! |
10357 ! ! |
10045 |
|
10046 |
10358 |
10047 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'! |
10359 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'error handling'! |
10048 |
10360 |
10049 error:anErrorSymbolOrErrno |
10361 error:anErrorSymbolOrErrno |
10050 "got an error; arg is either a symbol specifying a primitive error |
10362 "got an error; arg is either a symbol specifying a primitive error |
10054 (UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError |
10366 (UnixOperatingSystem errorHolderForNumber:anErrorSymbolOrErrno) reportError |
10055 ]. |
10367 ]. |
10056 self primitiveFailed:anErrorSymbolOrErrno. |
10368 self primitiveFailed:anErrorSymbolOrErrno. |
10057 ! ! |
10369 ! ! |
10058 |
10370 |
10059 |
|
10060 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'! |
10371 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'file access'! |
10061 |
10372 |
10062 close |
10373 close |
10063 "close the descriptor" |
10374 "close the descriptor" |
10064 |
10375 |
10068 self invalidate. |
10379 self invalidate. |
10069 ^ OperatingSystem closeFd:desc. |
10380 ^ OperatingSystem closeFd:desc. |
10070 |
10381 |
10071 "Modified: 30.9.1997 / 13:06:55 / stefan" |
10382 "Modified: 30.9.1997 / 13:06:55 / stefan" |
10072 ! ! |
10383 ! ! |
10073 |
|
10074 |
10384 |
10075 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'! |
10385 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'initialization'! |
10076 |
10386 |
10077 for:aFileDescriptor |
10387 for:aFileDescriptor |
10078 "create a file for a handle" |
10388 "create a file for a handle" |
10094 |
10404 |
10095 "Created: 26.9.1997 / 17:14:40 / stefan" |
10405 "Created: 26.9.1997 / 17:14:40 / stefan" |
10096 "Modified: 30.9.1997 / 12:41:43 / stefan" |
10406 "Modified: 30.9.1997 / 12:41:43 / stefan" |
10097 "Modified (comment): / 16-03-2013 / 00:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10407 "Modified (comment): / 16-03-2013 / 00:04:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10098 ! ! |
10408 ! ! |
10099 |
|
10100 |
10409 |
10101 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'! |
10410 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'input/output'! |
10102 |
10411 |
10103 readBytes:count into:aByteBuffer startingAt:firstIndex |
10412 readBytes:count into:aByteBuffer startingAt:firstIndex |
10104 "read count bytes into a byte-buffer; |
10413 "read count bytes into a byte-buffer; |
10370 buff := '12345678901234567890'. |
10679 buff := '12345678901234567890'. |
10371 n := h writeBytes:10 from:buff startingAt:1. |
10680 n := h writeBytes:10 from:buff startingAt:1. |
10372 " |
10681 " |
10373 ! ! |
10682 ! ! |
10374 |
10683 |
10375 |
|
10376 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'! |
10684 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'misc functions'! |
10377 |
10685 |
10378 nextError |
10686 nextError |
10379 "retrieve the pending error from the current fileDescriptor |
10687 "retrieve the pending error from the current fileDescriptor |
10380 and raise an error exception. |
10688 and raise an error exception. |
10527 ^ self primitiveFailed |
10835 ^ self primitiveFailed |
10528 |
10836 |
10529 |
10837 |
10530 ! ! |
10838 ! ! |
10531 |
10839 |
10532 |
|
10533 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'! |
10840 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'private-accessing'! |
10534 |
10841 |
10535 fileDescriptor |
10842 fileDescriptor |
10536 "return the (integer) fileDescriptor" |
10843 "return the (integer) fileDescriptor" |
10537 |
10844 |
10553 } |
10860 } |
10554 %} |
10861 %} |
10555 |
10862 |
10556 |
10863 |
10557 ! ! |
10864 ! ! |
10558 |
|
10559 |
10865 |
10560 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'! |
10866 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'queries'! |
10561 |
10867 |
10562 canReadWithoutBlocking |
10868 canReadWithoutBlocking |
10563 "return true, if data is available on a filedescriptor |
10869 "return true, if data is available on a filedescriptor |
10669 n := h numAvailableForRead. |
10975 n := h numAvailableForRead. |
10670 h close. |
10976 h close. |
10671 n |
10977 n |
10672 " |
10978 " |
10673 ! ! |
10979 ! ! |
10674 |
|
10675 |
10980 |
10676 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'! |
10981 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'registering'! |
10677 |
10982 |
10678 register |
10983 register |
10679 "register myself as an open file" |
10984 "register myself as an open file" |
10703 "Created: 30.9.1997 / 12:51:48 / stefan" |
11008 "Created: 30.9.1997 / 12:51:48 / stefan" |
10704 "Modified: 30.9.1997 / 12:58:37 / stefan" |
11009 "Modified: 30.9.1997 / 12:58:37 / stefan" |
10705 "Modified (comment): / 16-03-2013 / 00:04:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
11010 "Modified (comment): / 16-03-2013 / 00:04:38 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10706 ! ! |
11011 ! ! |
10707 |
11012 |
10708 |
|
10709 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'! |
11013 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'releasing'! |
10710 |
11014 |
10711 invalidate |
11015 invalidate |
10712 "a file handle has become invalid" |
11016 "a file handle has become invalid" |
10713 |
11017 |
10715 fd := nil. |
11019 fd := nil. |
10716 |
11020 |
10717 "Created: 30.9.1997 / 12:37:26 / stefan" |
11021 "Created: 30.9.1997 / 12:37:26 / stefan" |
10718 "Modified: 30.9.1997 / 12:42:16 / stefan" |
11022 "Modified: 30.9.1997 / 12:42:16 / stefan" |
10719 ! ! |
11023 ! ! |
10720 |
|
10721 |
11024 |
10722 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'! |
11025 !UnixOperatingSystem::FileDescriptorHandle methodsFor:'waiting'! |
10723 |
11026 |
10724 readWaitWithTimeoutMs:timeout |
11027 readWaitWithTimeoutMs:timeout |
10725 "suspend the current process, until the receiver |
11028 "suspend the current process, until the receiver |
10785 ]. |
11088 ]. |
10786 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
11089 wasBlocked ifFalse:[OperatingSystem unblockInterrupts]. |
10787 ^ canWrite not |
11090 ^ canWrite not |
10788 ! ! |
11091 ! ! |
10789 |
11092 |
10790 |
|
10791 !UnixOperatingSystem::FilePointerHandle methodsFor:'release'! |
11093 !UnixOperatingSystem::FilePointerHandle methodsFor:'release'! |
10792 |
11094 |
10793 closeFile |
11095 closeFile |
10794 "close the underlying file" |
11096 "close the underlying file" |
10795 |
11097 |
10801 fclose(f); |
11103 fclose(f); |
10802 } |
11104 } |
10803 %} |
11105 %} |
10804 |
11106 |
10805 ! ! |
11107 ! ! |
10806 |
|
10807 |
11108 |
10808 !UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'! |
11109 !UnixOperatingSystem::FileStatusInfo class methodsFor:'instance creation'! |
10809 |
11110 |
10810 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL |
11111 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL |
10811 ^ self basicNew |
11112 ^ self basicNew |
10812 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL |
11113 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL |
10813 ! ! |
11114 ! ! |
10814 |
|
10815 |
11115 |
10816 !UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'! |
11116 !UnixOperatingSystem::FileStatusInfo methodsFor:'accessing'! |
10817 |
11117 |
10818 accessTime |
11118 accessTime |
10819 "return accessed" |
11119 "return accessed" |
10901 "return uid" |
11201 "return uid" |
10902 |
11202 |
10903 ^ uid |
11203 ^ uid |
10904 ! ! |
11204 ! ! |
10905 |
11205 |
10906 |
|
10907 !UnixOperatingSystem::FileStatusInfo methodsFor:'accessing-vms'! |
11206 !UnixOperatingSystem::FileStatusInfo methodsFor:'accessing-vms'! |
10908 |
11207 |
10909 fixedHeaderSize |
11208 fixedHeaderSize |
10910 "return the fixedHeaderSize (VMS only; nil everywhere else)" |
11209 "return the fixedHeaderSize (VMS only; nil everywhere else)" |
10911 |
11210 |
10933 recordSize |
11232 recordSize |
10934 "return the recordSize (VMS only; nil everywhere else)" |
11233 "return the recordSize (VMS only; nil everywhere else)" |
10935 |
11234 |
10936 ^ nil |
11235 ^ nil |
10937 ! ! |
11236 ! ! |
10938 |
|
10939 |
11237 |
10940 !UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'! |
11238 !UnixOperatingSystem::FileStatusInfo methodsFor:'backward compatibility'! |
10941 |
11239 |
10942 accessed |
11240 accessed |
10943 <resource:#obsolete> |
11241 <resource:#obsolete> |
10965 <resource:#obsolete> |
11263 <resource:#obsolete> |
10966 |
11264 |
10967 self obsoleteMethodWarning:'use #statusChangeTime'. |
11265 self obsoleteMethodWarning:'use #statusChangeTime'. |
10968 ^ self statusChangeTime |
11266 ^ self statusChangeTime |
10969 ! ! |
11267 ! ! |
10970 |
|
10971 |
11268 |
10972 !UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'! |
11269 !UnixOperatingSystem::FileStatusInfo methodsFor:'private-accessing'! |
10973 |
11270 |
10974 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL |
11271 type:t mode:m uid:u gid:g size:s id:i accessed:aT modified:mT statusChanged:sT path:lP numLinks:nL |
10975 type := t. |
11272 type := t. |
10983 statusChanged := sT. |
11280 statusChanged := sT. |
10984 path := lP. |
11281 path := lP. |
10985 numLinks := nL. |
11282 numLinks := nL. |
10986 ! ! |
11283 ! ! |
10987 |
11284 |
10988 |
|
10989 !UnixOperatingSystem::FileStatusInfo methodsFor:'queries-access'! |
11285 !UnixOperatingSystem::FileStatusInfo methodsFor:'queries-access'! |
10990 |
11286 |
10991 isGroupExecutable |
11287 isGroupExecutable |
10992 ^ mode bitTest:8r10 |
11288 ^ mode bitTest:8r10 |
10993 |
11289 |
11057 |
11353 |
11058 " |
11354 " |
11059 '/etc/passwd' asFilename info isWorldWritable |
11355 '/etc/passwd' asFilename info isWorldWritable |
11060 " |
11356 " |
11061 ! ! |
11357 ! ! |
11062 |
|
11063 |
11358 |
11064 !UnixOperatingSystem::FileStatusInfo methodsFor:'queries-type'! |
11359 !UnixOperatingSystem::FileStatusInfo methodsFor:'queries-type'! |
11065 |
11360 |
11066 isBlockSpecial |
11361 isBlockSpecial |
11067 ^ type == #blockSpecial |
11362 ^ type == #blockSpecial |
11092 ! |
11387 ! |
11093 |
11388 |
11094 isUnknown |
11389 isUnknown |
11095 ^ type == #unknown |
11390 ^ type == #unknown |
11096 ! ! |
11391 ! ! |
11097 |
|
11098 |
11392 |
11099 !UnixOperatingSystem::MountInfo methodsFor:'accessing'! |
11393 !UnixOperatingSystem::MountInfo methodsFor:'accessing'! |
11100 |
11394 |
11101 mountPointPath |
11395 mountPointPath |
11102 "return the value of the instance variable 'mountPointPath' (automatically generated)" |
11396 "return the value of the instance variable 'mountPointPath' (automatically generated)" |
11111 deviceOrRemotePath := deviceOrRemotePathArg. |
11405 deviceOrRemotePath := deviceOrRemotePathArg. |
11112 fsType := fsTypeArg. |
11406 fsType := fsTypeArg. |
11113 attributeString := attributeStringArg. |
11407 attributeString := attributeStringArg. |
11114 ! ! |
11408 ! ! |
11115 |
11409 |
11116 |
|
11117 !UnixOperatingSystem::MountInfo methodsFor:'printing'! |
11410 !UnixOperatingSystem::MountInfo methodsFor:'printing'! |
11118 |
11411 |
11119 printOn:aStream |
11412 printOn:aStream |
11120 aStream |
11413 aStream |
11121 nextPutAll:'MountInfo for '; |
11414 nextPutAll:'MountInfo for '; |
11122 nextPutAll:mountPointPath. |
11415 nextPutAll:mountPointPath. |
11123 ! ! |
11416 ! ! |
11124 |
11417 |
11125 |
|
11126 !UnixOperatingSystem::MountInfo methodsFor:'queries'! |
11418 !UnixOperatingSystem::MountInfo methodsFor:'queries'! |
11127 |
11419 |
11128 isRemote |
11420 isRemote |
11129 ^ fsType = 'nfs' |
11421 ^ fsType = 'nfs' |
11130 ! ! |
11422 ! ! |
11131 |
|
11132 |
11423 |
11133 !UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'! |
11424 !UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'! |
11134 |
11425 |
11135 documentation |
11426 documentation |
11136 " |
11427 " |
11154 [see also:] |
11445 [see also:] |
11155 OperatingSystem |
11446 OperatingSystem |
11156 " |
11447 " |
11157 ! ! |
11448 ! ! |
11158 |
11449 |
11159 |
|
11160 !UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'! |
11450 !UnixOperatingSystem::OSProcessStatus class methodsFor:'instance creation'! |
11161 |
11451 |
11162 pid:pid status:status code:code core:core |
11452 pid:pid status:status code:code core:core |
11163 "private interface for UnixOperatingSystem" |
11453 "private interface for UnixOperatingSystem" |
11164 |
11454 |
11175 |
11465 |
11176 "Created: 28.12.1995 / 14:35:29 / stefan" |
11466 "Created: 28.12.1995 / 14:35:29 / stefan" |
11177 "Modified: 30.4.1996 / 18:25:05 / cg" |
11467 "Modified: 30.4.1996 / 18:25:05 / cg" |
11178 ! ! |
11468 ! ! |
11179 |
11469 |
11180 |
|
11181 !UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'! |
11470 !UnixOperatingSystem::OSProcessStatus methodsFor:'accessing'! |
11182 |
11471 |
11183 code |
11472 code |
11184 "return the exitcode / signalNumber" |
11473 "return the exitcode / signalNumber" |
11185 |
11474 |
11213 ^ status |
11502 ^ status |
11214 |
11503 |
11215 "Created: 28.12.1995 / 14:05:07 / stefan" |
11504 "Created: 28.12.1995 / 14:05:07 / stefan" |
11216 "Modified: 30.4.1996 / 18:26:54 / cg" |
11505 "Modified: 30.4.1996 / 18:26:54 / cg" |
11217 ! ! |
11506 ! ! |
11218 |
|
11219 |
11507 |
11220 !UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'! |
11508 !UnixOperatingSystem::OSProcessStatus methodsFor:'initialization'! |
11221 |
11509 |
11222 pid:newPid status:newStatus code:newCode core:newCore |
11510 pid:newPid status:newStatus code:newCode core:newCore |
11223 pid := newPid. |
11511 pid := newPid. |
11225 code := newCode. |
11513 code := newCode. |
11226 core := newCore. |
11514 core := newCore. |
11227 |
11515 |
11228 "Created: 28.12.1995 / 14:18:22 / stefan" |
11516 "Created: 28.12.1995 / 14:18:22 / stefan" |
11229 ! ! |
11517 ! ! |
11230 |
|
11231 |
11518 |
11232 !UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'! |
11519 !UnixOperatingSystem::OSProcessStatus methodsFor:'printing & storing'! |
11233 |
11520 |
11234 printOn:aStream |
11521 printOn:aStream |
11235 |
11522 |
11238 aStream nextPutAll:', code='. |
11525 aStream nextPutAll:', code='. |
11239 code printOn:aStream. |
11526 code printOn:aStream. |
11240 aStream nextPut:$). |
11527 aStream nextPut:$). |
11241 ! ! |
11528 ! ! |
11242 |
11529 |
11243 |
|
11244 !UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'! |
11530 !UnixOperatingSystem::OSProcessStatus methodsFor:'private-OS interface'! |
11245 |
11531 |
11246 code:something |
11532 code:something |
11247 "set the exitCode" |
11533 "set the exitCode" |
11248 |
11534 |
11273 |
11559 |
11274 status := something. |
11560 status := something. |
11275 |
11561 |
11276 "Created: 28.12.1995 / 14:05:07 / stefan" |
11562 "Created: 28.12.1995 / 14:05:07 / stefan" |
11277 ! ! |
11563 ! ! |
11278 |
|
11279 |
11564 |
11280 !UnixOperatingSystem::OSProcessStatus methodsFor:'queries'! |
11565 !UnixOperatingSystem::OSProcessStatus methodsFor:'queries'! |
11281 |
11566 |
11282 couldNotExecute |
11567 couldNotExecute |
11283 "return true when a command could not be executed" |
11568 "return true when a command could not be executed" |
11302 ^ status == #exit and:[code = 0] |
11587 ^ status == #exit and:[code = 0] |
11303 |
11588 |
11304 "Created: 28.12.1995 / 14:13:05 / stefan" |
11589 "Created: 28.12.1995 / 14:13:05 / stefan" |
11305 "Modified: 28.12.1995 / 14:13:41 / stefan" |
11590 "Modified: 28.12.1995 / 14:13:41 / stefan" |
11306 ! ! |
11591 ! ! |
11307 |
|
11308 |
11592 |
11309 !UnixOperatingSystem::SocketHandle class methodsFor:'constants'! |
11593 !UnixOperatingSystem::SocketHandle class methodsFor:'constants'! |
11310 |
11594 |
11311 protocolCodeOf:aNameOrNumber |
11595 protocolCodeOf:aNameOrNumber |
11312 "convert a symbol to a numeric protocol code" |
11596 "convert a symbol to a numeric protocol code" |
11395 self protocolSymbolOf:(self protocolCodeOf:#udp) |
11679 self protocolSymbolOf:(self protocolCodeOf:#udp) |
11396 self protocolSymbolOf:(self protocolCodeOf:#icmp) |
11680 self protocolSymbolOf:(self protocolCodeOf:#icmp) |
11397 " |
11681 " |
11398 ! ! |
11682 ! ! |
11399 |
11683 |
11400 |
|
11401 !UnixOperatingSystem::SocketHandle class methodsFor:'initialization'! |
11684 !UnixOperatingSystem::SocketHandle class methodsFor:'initialization'! |
11402 |
11685 |
11403 reinitialize |
11686 reinitialize |
11404 "clear the protocol cache, when the system has been restarted" |
11687 "clear the protocol cache, when the system has been restarted" |
11405 |
11688 |
11406 ProtocolCache := nil. |
11689 ProtocolCache := nil. |
11407 ! ! |
11690 ! ! |
11408 |
|
11409 |
11691 |
11410 !UnixOperatingSystem::SocketHandle class methodsFor:'queries'! |
11692 !UnixOperatingSystem::SocketHandle class methodsFor:'queries'! |
11411 |
11693 |
11412 XXgetAddressInfo:hostName serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags |
11694 XXgetAddressInfo:hostName serviceName:serviceNameArg domain:domainArg type:typeArg protocol:protoArg flags:flags |
11413 "answer an Array of socket addresses for serviceName on hostName |
11695 "answer an Array of socket addresses for serviceName on hostName |
12405 ^ error. |
12687 ^ error. |
12406 ]. |
12688 ]. |
12407 ^ result. |
12689 ^ result. |
12408 ! ! |
12690 ! ! |
12409 |
12691 |
12410 |
|
12411 !UnixOperatingSystem::SocketHandle methodsFor:'accepting'! |
12692 !UnixOperatingSystem::SocketHandle methodsFor:'accepting'! |
12412 |
12693 |
12413 acceptWithPeerAddressBuffer:peerOrNil |
12694 acceptWithPeerAddressBuffer:peerOrNil |
12414 "accept a connection on a server port. |
12695 "accept a connection on a server port. |
12415 Returns a new SocketHandle or nil if the operation |
12696 Returns a new SocketHandle or nil if the operation |
12479 ^ self error:error. |
12760 ^ self error:error. |
12480 ]. |
12761 ]. |
12481 ^ self class for:newFd |
12762 ^ self class for:newFd |
12482 ! ! |
12763 ! ! |
12483 |
12764 |
12484 |
|
12485 !UnixOperatingSystem::SocketHandle methodsFor:'binding'! |
12765 !UnixOperatingSystem::SocketHandle methodsFor:'binding'! |
12486 |
12766 |
12487 bindTo:socketAddress |
12767 bindTo:socketAddress |
12488 "low level bind - |
12768 "low level bind - |
12489 Set the local address of the socket" |
12769 Set the local address of the socket" |
12533 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999) |
12813 bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999) |
12534 reuseAddress:false ; |
12814 reuseAddress:false ; |
12535 yourself |
12815 yourself |
12536 " |
12816 " |
12537 ! ! |
12817 ! ! |
12538 |
|
12539 |
12818 |
12540 !UnixOperatingSystem::SocketHandle methodsFor:'connecting'! |
12819 !UnixOperatingSystem::SocketHandle methodsFor:'connecting'! |
12541 |
12820 |
12542 cancelConnect |
12821 cancelConnect |
12543 "cancel an asynchronous connect in progress" |
12822 "cancel an asynchronous connect in progress" |
12656 withTimeout:nil. |
12935 withTimeout:nil. |
12657 Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7) |
12936 Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7) |
12658 withTimeout:nil. |
12937 withTimeout:nil. |
12659 " |
12938 " |
12660 ! ! |
12939 ! ! |
12661 |
|
12662 |
12940 |
12663 !UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'! |
12941 !UnixOperatingSystem::SocketHandle methodsFor:'datagram transmission'! |
12664 |
12942 |
12665 receiveFrom:socketAddress buffer:aDataBuffer start:startIndex for:nBytes flags:flags |
12943 receiveFrom:socketAddress buffer:aDataBuffer start:startIndex for:nBytes flags:flags |
12666 "receive datagramm data - put address of originating host into |
12944 "receive datagramm data - put address of originating host into |
12894 err: ; |
13172 err: ; |
12895 %}. |
13173 %}. |
12896 ^ self error:error. |
13174 ^ self error:error. |
12897 ! ! |
13175 ! ! |
12898 |
13176 |
12899 |
|
12900 !UnixOperatingSystem::SocketHandle methodsFor:'initialization'! |
13177 !UnixOperatingSystem::SocketHandle methodsFor:'initialization'! |
12901 |
13178 |
12902 domain:domainArg type:typeArg protocol:protocolArg |
13179 domain:domainArg type:typeArg protocol:protocolArg |
12903 "set up socket with domain, type and protocol number. |
13180 "set up socket with domain, type and protocol number. |
12904 This is a low level entry; no binding, listening or connect is done. |
13181 This is a low level entry; no binding, listening or connect is done. |
12980 " |
13257 " |
12981 self new domain:#inet type:#stream protocol:nil |
13258 self new domain:#inet type:#stream protocol:nil |
12982 " |
13259 " |
12983 ! ! |
13260 ! ! |
12984 |
13261 |
12985 |
|
12986 !UnixOperatingSystem::SocketHandle methodsFor:'misc'! |
13262 !UnixOperatingSystem::SocketHandle methodsFor:'misc'! |
12987 |
13263 |
12988 getOptionsLevel:level name:name |
13264 getOptionsLevel:level name:name |
12989 "answer a ByteArray containing the socket option value |
13265 "answer a ByteArray containing the socket option value |
12990 named name at level" |
13266 named name at level" |
13172 ^ self error:error |
13448 ^ self error:error |
13173 ]. |
13449 ]. |
13174 ^ nil. |
13450 ^ nil. |
13175 ! ! |
13451 ! ! |
13176 |
13452 |
13177 |
|
13178 !UnixOperatingSystem::SocketHandle methodsFor:'queries'! |
13453 !UnixOperatingSystem::SocketHandle methodsFor:'queries'! |
13179 |
13454 |
13180 getNameInto:socketAddress |
13455 getNameInto:socketAddress |
13181 "answer the my own address (I am bound to this address). |
13456 "answer the my own address (I am bound to this address). |
13182 Note that this address may change after connect or accept." |
13457 Note that this address may change after connect or accept." |
13250 ^ self error:error |
13525 ^ self error:error |
13251 ]. |
13526 ]. |
13252 ^ nil |
13527 ^ nil |
13253 ! ! |
13528 ! ! |
13254 |
13529 |
13255 |
|
13256 !UnixOperatingSystem class methodsFor:'documentation'! |
13530 !UnixOperatingSystem class methodsFor:'documentation'! |
13257 |
13531 |
13258 version |
13532 version |
13259 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.309 2013-04-22 15:51:25 stefan Exp $' |
13533 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.312 2013-04-25 09:23:16 stefan Exp $' |
13260 ! |
13534 ! |
13261 |
13535 |
13262 version_CVS |
13536 version_CVS |
13263 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.309 2013-04-22 15:51:25 stefan Exp $' |
13537 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.312 2013-04-25 09:23:16 stefan Exp $' |
13264 ! |
13538 ! |
13265 |
13539 |
13266 version_HG |
13540 version_HG |
13267 |
13541 |
13268 ^ '$Changeset: <not expanded> $' |
13542 ^ '$Changeset: <not expanded> $' |
13269 ! ! |
13543 ! ! |
13270 |
13544 |
13271 |
13545 |
13546 UnixOperatingSystem initialize! |
|
13272 UnixOperatingSystem::FileDescriptorHandle initialize! |
13547 UnixOperatingSystem::FileDescriptorHandle initialize! |
13273 UnixOperatingSystem initialize! |