-
Notifications
You must be signed in to change notification settings - Fork 0
/
f_chmod.f90
124 lines (124 loc) · 3.25 KB
/
f_chmod.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
!-----------------------------------------------------------------------
!
! IMPORTANT:
! 1. all integers are given in decimal presentation.
! 2. to determine an octal value in decimal presention, we have
! to translate. For example, n=777 should become 511 if n is
! defined as an octal number.
!
! mode of directory is given as an integer with octal value, moct.
! For instance, let
! moct = 777
! Without explanation, we always consider moct in decimal mode, i.e.
! moct = 7x10^2 + 7x10^1 + 7
! However, calling funx_chmod ( path, moct, errno ) implies
! moct = 7x8^2 + 7x8^1 + 7 = 511
! So, we have to translate moct=777 to 511 using funx_dec2oct.
! Thus, in fact, we will perform
! call funx_chmod ( path, 511, errno )
! The c_chmod will read 511 as 777 in octal presentation, as designed.
!-----------------------------------------------------------------------
!
! Level 1: it has the highest responsible.
!
!-----
!
! mode of directory is given as mdec with decimal value.
!
subroutine f_chmod_decf ( path, mdec )
!
use mod_funx_param, only: ck_char_nul, ck_mode_t
implicit none
!
! include 'i_param.inc'
!
character(len=*),intent(in) :: path
integer(kind=ck_mode_t),intent(in) :: mdec
!
external c_chmod
!
!
call c_chmod ( path//ck_char_nul, mdec )
!
end subroutine f_chmod_decf
!
!-----
!
subroutine f_chmod_octf ( path, moct )
!
use mod_funx_param, only: ck_int, ck_mode_t
implicit none
!
! include 'i_param.inc'
!
character(len=*),intent(in) :: path
integer(kind=ck_mode_t),intent(in) :: moct
!
external f_chmod_decf, f_utils_oct2dec
integer(kind=ck_mode_t) mdec
!
!
call f_utils_oct2dec ( moct, mdec )
call f_chmod_decf ( path, mdec )
!
end subroutine f_chmod_octf
!
!-----
!
! Next, let us define subroutine working with mask in the character
! form:
!
! 123456789
! ---------
! fmt= 'rwxrwxrwx'
! ---___---
! U G O U:user, G:group, O:others
!
! For example, with the input mask
!
! fmt = 'rwxr--r--'
!
! the output directory has persission:
! + User (onwer) can read, write, execute
! + Group can read only.
! + Others can only read.
!
!
subroutine f_chmod_perm ( path, perm )
!
use mod_funx_param, only: ck_int, ck_mode_t
implicit none
!
! include 'i_param.inc'
!
character(len=*),intent(in) :: path
character(len=*),intent(in) :: perm
!
external f_chmod_decf, f_utils_per2dec
integer(kind=ck_mode_t) mdec
!
!
call f_utils_per2dec ( perm, mdec )
call f_chmod_decf ( path, mdec )
!
end subroutine f_chmod_perm
!
!-----
!
subroutine f_chmod ( path, mdec )
!
use mod_funx_param, only: ck_int, ck_mode_t
implicit none
!
! include 'i_param.inc'
!
character(len=*),intent(in) :: path
integer(kind=ck_mode_t),intent(in) :: mdec
!
external f_chmod_decf
!
call f_chmod_decf ( path, mdec )
!
end subroutine f_chmod
!
!-----------------------------------------------------------------------