11
2- /*
2+ /*
33 * rename_device.c: udev helper to rename ethernet devices.
44 *
55 * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved.
99 * GNU General Public License v.2.
1010 *
1111 * This program is distributed in the hope that it will be useful, but WITHOUT
12- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
1414 * more details.
1515 *
1616 * You should have received a copy of the GNU General Public License along
@@ -64,7 +64,7 @@ struct tmp *tmplist = NULL;
6464#if defined(__s390__ ) || defined(__s390x__ )
6565static int is_cdev (const struct dirent * dent ) {
6666 char * end = NULL ;
67-
67+
6868 if (strncmp (dent -> d_name ,"cdev" ,4 ))
6969 return 0 ;
7070 strtoul (dent -> d_name + 4 ,& end , 10 );
@@ -75,7 +75,7 @@ static int is_cdev(const struct dirent *dent) {
7575
7676static inline char * getdev (char * path , char * ent ) {
7777 char * a , * b , * ret ;
78-
78+
7979 asprintf (& a ,"%s/%s" ,path ,ent );
8080 b = canonicalize_file_name (a );
8181 ret = strdup (basename (b ));
@@ -88,13 +88,13 @@ char *read_subchannels(char *path) {
8888 char * tmp , * ret ;
8989 int n , x ;
9090 struct dirent * * cdevs ;
91-
91+
9292 if ((n = scandir (path , & cdevs , is_cdev , alphasort )) <= 0 )
9393 return NULL ;
94-
94+
9595 ret = getdev (path ,cdevs [0 ]-> d_name );
96- for (x = 1 ; x < n ; x ++ ) {
97- if (asprintf (& tmp , "%s,%s" , ret , getdev (path , cdevs [x ]-> d_name )) == -1 )
96+ for (x = 1 ; x < n ; x ++ ) {
97+ if (asprintf (& tmp , "%s,%s" , ret , getdev (path , cdevs [x ]-> d_name )) == -1 )
9898 return NULL ;
9999 free (ret );
100100 ret = tmp ;
@@ -172,9 +172,9 @@ struct netdev *get_configs() {
172172 struct netdev * ret , * tmpdev ;
173173 struct dirent * * cfgs ;
174174 int x ;
175-
175+
176176 ret = NULL ;
177-
177+
178178 if ((ncfgs = scandir ("/etc/sysconfig/network-scripts" ,& cfgs ,
179179 isCfg , alphasort )) == -1 ) {
180180 return ret ;
@@ -185,7 +185,7 @@ struct netdev *get_configs() {
185185 int vlan ;
186186 gchar * contents , * * lines ;
187187 int i ;
188-
188+
189189 devname = hwaddr = contents = NULL ;
190190 lines = NULL ;
191191 vlan = 0 ;
@@ -235,7 +235,7 @@ struct netdev *get_configs() {
235235 free (cfgs );
236236 return ret ;
237237}
238-
238+
239239char * get_hwaddr (char * device ) {
240240 char * path = NULL ;
241241 char * contents = NULL ;
@@ -260,13 +260,13 @@ char *get_hwaddr(char *device) {
260260
261261 return g_strstrip (contents );
262262}
263-
263+
264264char * get_config_by_hwaddr (char * hwaddr , char * current ) {
265265 struct netdev * config ;
266266 char * first = NULL ;
267-
267+
268268 if (!hwaddr ) return NULL ;
269-
269+
270270 for (config = configs ; config ; config = config -> next ) {
271271 if (strcasecmp (config -> hwaddr , hwaddr ) != 0 )
272272 continue ;
@@ -322,7 +322,7 @@ void take_lock() {
322322 int count = 0 ;
323323 int lockfd ;
324324 ssize_t ignored_retval __attribute__((unused ));
325-
325+
326326 while (1 ) {
327327 lockfd = open (LOCKFILE , O_RDWR |O_CREAT |O_EXCL , 0644 );
328328 if (lockfd != -1 ) {
@@ -341,7 +341,7 @@ void take_lock() {
341341 int fd ;
342342 char buf [32 ];
343343 int pid ;
344-
344+
345345 fd = open (LOCKFILE , O_RDONLY );
346346 if (fd == -1 )
347347 break ;
@@ -364,16 +364,16 @@ int main(int argc, char **argv) {
364364 struct timeval tv ;
365365
366366 gettimeofday (& tv , NULL );
367- srand (tv .tv_usec );
367+ srand (tv .tv_usec );
368368 take_lock ();
369-
369+
370370 signal (SIGSEGV ,sighandler );
371371 signal (SIGKILL ,sighandler );
372372 signal (SIGTERM ,sighandler );
373373 signal (SIGSEGV ,sighandler );
374374 signal (SIGALRM ,sighandler );
375375 alarm (10 );
376-
376+
377377 src = getenv ("INTERFACE" );
378378 if (!src )
379379 goto out_unlock ;
@@ -390,7 +390,7 @@ int main(int argc, char **argv) {
390390 goto out_unlock ;
391391
392392 printf ("%s" , target );
393-
393+
394394out_unlock :
395395 unlink (LOCKFILE );
396396 exit (0 );
0 commit comments