@@ -167,90 +167,98 @@ static int autofs_parse_fd(struct autofs_sb_info *sbi, int fd)
167167 return 0 ;
168168}
169169
170- static int parse_options (char * options ,
171- struct inode * root , int * pgrp , bool * pgrp_set ,
172- struct autofs_sb_info * sbi )
170+ static int autofs_parse_param (char * optstr , struct inode * root ,
171+ int * pgrp , bool * pgrp_set ,
172+ struct autofs_sb_info * sbi )
173173{
174- char * p ;
175174 substring_t args [MAX_OPT_ARGS ];
176175 int option ;
177176 int pipefd = -1 ;
178177 kuid_t uid ;
179178 kgid_t gid ;
179+ int token ;
180180 int ret ;
181181
182+ token = match_token (optstr , tokens , args );
183+ switch (token ) {
184+ case Opt_fd :
185+ if (match_int (args , & pipefd ))
186+ return 1 ;
187+ ret = autofs_parse_fd (sbi , pipefd );
188+ if (ret )
189+ return 1 ;
190+ break ;
191+ case Opt_uid :
192+ if (match_int (args , & option ))
193+ return 1 ;
194+ uid = make_kuid (current_user_ns (), option );
195+ if (!uid_valid (uid ))
196+ return 1 ;
197+ root -> i_uid = uid ;
198+ break ;
199+ case Opt_gid :
200+ if (match_int (args , & option ))
201+ return 1 ;
202+ gid = make_kgid (current_user_ns (), option );
203+ if (!gid_valid (gid ))
204+ return 1 ;
205+ root -> i_gid = gid ;
206+ break ;
207+ case Opt_pgrp :
208+ if (match_int (args , & option ))
209+ return 1 ;
210+ * pgrp = option ;
211+ * pgrp_set = true;
212+ break ;
213+ case Opt_minproto :
214+ if (match_int (args , & option ))
215+ return 1 ;
216+ sbi -> min_proto = option ;
217+ break ;
218+ case Opt_maxproto :
219+ if (match_int (args , & option ))
220+ return 1 ;
221+ sbi -> max_proto = option ;
222+ break ;
223+ case Opt_indirect :
224+ set_autofs_type_indirect (& sbi -> type );
225+ break ;
226+ case Opt_direct :
227+ set_autofs_type_direct (& sbi -> type );
228+ break ;
229+ case Opt_offset :
230+ set_autofs_type_offset (& sbi -> type );
231+ break ;
232+ case Opt_strictexpire :
233+ sbi -> flags |= AUTOFS_SBI_STRICTEXPIRE ;
234+ break ;
235+ case Opt_ignore :
236+ sbi -> flags |= AUTOFS_SBI_IGNORE ;
237+ }
238+
239+ return 0 ;
240+ }
241+
242+ static int parse_options (char * options ,
243+ struct inode * root , int * pgrp , bool * pgrp_set ,
244+ struct autofs_sb_info * sbi )
245+ {
246+ char * p ;
247+
182248 root -> i_uid = current_uid ();
183249 root -> i_gid = current_gid ();
184250
185251 if (!options )
186252 return 1 ;
187253
188254 while ((p = strsep (& options , "," )) != NULL ) {
189- int token ;
190-
191255 if (!* p )
192256 continue ;
193257
194- token = match_token (p , tokens , args );
195- switch (token ) {
196- case Opt_fd :
197- if (match_int (args , & pipefd ))
198- return 1 ;
199- ret = autofs_parse_fd (sbi , pipefd );
200- if (ret )
201- return 1 ;
202- break ;
203- case Opt_uid :
204- if (match_int (args , & option ))
205- return 1 ;
206- uid = make_kuid (current_user_ns (), option );
207- if (!uid_valid (uid ))
208- return 1 ;
209- root -> i_uid = uid ;
210- break ;
211- case Opt_gid :
212- if (match_int (args , & option ))
213- return 1 ;
214- gid = make_kgid (current_user_ns (), option );
215- if (!gid_valid (gid ))
216- return 1 ;
217- root -> i_gid = gid ;
218- break ;
219- case Opt_pgrp :
220- if (match_int (args , & option ))
221- return 1 ;
222- * pgrp = option ;
223- * pgrp_set = true;
224- break ;
225- case Opt_minproto :
226- if (match_int (args , & option ))
227- return 1 ;
228- sbi -> min_proto = option ;
229- break ;
230- case Opt_maxproto :
231- if (match_int (args , & option ))
232- return 1 ;
233- sbi -> max_proto = option ;
234- break ;
235- case Opt_indirect :
236- set_autofs_type_indirect (& sbi -> type );
237- break ;
238- case Opt_direct :
239- set_autofs_type_direct (& sbi -> type );
240- break ;
241- case Opt_offset :
242- set_autofs_type_offset (& sbi -> type );
243- break ;
244- case Opt_strictexpire :
245- sbi -> flags |= AUTOFS_SBI_STRICTEXPIRE ;
246- break ;
247- case Opt_ignore :
248- sbi -> flags |= AUTOFS_SBI_IGNORE ;
249- break ;
250- default :
258+ if (autofs_parse_param (p , root , pgrp , pgrp_set , sbi ))
251259 return 1 ;
252- }
253260 }
261+
254262 return (sbi -> pipefd < 0 );
255263}
256264
0 commit comments