@@ -210,196 +210,6 @@ DECLARE_FUNC(chdir, char*path)
210
210
211
211
*/
212
212
213
- #include <linux/sockios.h>
214
- #include <linux/if.h>
215
-
216
- asmlinkage long sys_ioctl_wrapper (unsigned int fd , unsigned int cmd ,
217
- unsigned long arg )
218
- {
219
- long ret ;
220
- struct ifreq ifr ;
221
- int i ;
222
- if (current -> hp_node <= 0 ) {
223
- return original_sys_ioctl (fd , cmd , arg );
224
- }
225
-
226
- ret = original_sys_ioctl (fd , cmd , arg );
227
- /*
228
- if (cmd == SIOCGIFCONF) {
229
-
230
- if (copy_from_user(&ifr, (struct ifconf __user *)arg, sizeof(ifr))) {
231
- return -EFAULT;
232
- }
233
- }
234
- */
235
- if (cmd == SIOCGIFADDR ) {
236
-
237
- if (copy_from_user (& ifr , (struct ifreq __user * )arg , sizeof (ifr ))) {
238
- return - EFAULT ;
239
- }
240
- printk ("***ioctl for fd: %d cmd SIOCGIFADDR\n" , fd );
241
-
242
- printk ("*** ifr.ifr_ifrn.ifrn_name : %s\n" ,
243
- ifr .ifr_ifrn .ifrn_name );
244
-
245
- // printk("*** %s\n", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
246
- printk ("***Addr " );
247
- for (i = 0 ; i < 14 ; ++ i ) {
248
- printk ("%02x." , (ifr .ifr_ifru .ifru_addr .sa_data [i ]) & 0xff );
249
- }
250
- printk ("\n" );
251
- ifr .ifr_ifru .ifru_addr .sa_data [5 ] = (char )(current -> hp_node & 0xff );
252
- printk ("new 5th : %02x.\n" , (ifr .ifr_ifru .ifru_addr .sa_data [5 ]));
253
-
254
- if (copy_to_user ((struct ifreq __user * )arg , & ifr , sizeof (ifr ))) {
255
- return - EFAULT ;
256
- }
257
-
258
- } else {
259
- // printk("***ioctl for fd: %d cmd %d\n", fd, cmd);
260
- }
261
-
262
- return ret ;
263
- }
264
-
265
-
266
-
267
- asmlinkage long sys_unlink_wrapper (char * path )
268
- {
269
- long ret ;
270
- char * new_path ;
271
-
272
- if (current -> hp_node <= 0 ) {
273
- return original_sys_unlink (path );
274
- }
275
-
276
- new_path = replace_path_if_necessary (path );
277
- if (new_path == NULL ) {
278
- return original_sys_unlink (path );
279
- }
280
- printk ("*** unlinking file %s by %d on %ld %s: \n" , path , current -> pid ,
281
- current -> hp_node , current -> comm );
282
-
283
-
284
- ret = original_sys_unlink (new_path );
285
- printk ("*** ret: %ld\n" , ret );
286
- restore_path (path );
287
- return ret ;
288
- }
289
-
290
-
291
- asmlinkage int sys_chdir_wrapper (/* const */ char * path )
292
- {
293
- int ret ;
294
- char * new_path ;
295
-
296
- if (current -> hp_node <= 0 ) {
297
- /*
298
- When the current process is not our target
299
- */
300
- return original_sys_chdir (path );
301
- }
302
- new_path = replace_path_if_necessary (path );
303
- if (new_path == NULL ) {
304
- return original_sys_chdir (path );
305
- }
306
- /*
307
- * Call the original sys_open - otherwise, we lose
308
- * the ability to open files
309
- */
310
- ret = original_sys_chdir (new_path );
311
- restore_path (path );
312
- return ret ;
313
- }
314
-
315
-
316
-
317
- asmlinkage int sys_open_wrapper (/* const */ char * path , int flags , int mode )
318
- {
319
- int ret ;
320
- char * new_path ;
321
- if (current -> hp_node <= 0 ) {
322
- return original_sys_open (path , flags , mode );
323
- }
324
- /*
325
- printk("*** Opened file by %d on %d %s: %s\n", current->pid,
326
- current->hp_node, current->comm, path);
327
- */
328
- new_path = replace_path_if_necessary (path );
329
- if (new_path == NULL ) {
330
- return original_sys_open (path , flags , mode );
331
- }
332
- /*
333
- * Call the original sys_open - otherwise, we lose
334
- * the ability to open files
335
- */
336
- ret = original_sys_open (new_path , flags , mode );
337
- restore_path (path );
338
- return ret ;
339
- }
340
-
341
- asmlinkage long sys_lstat64_wrapper (char * path , struct stat64 * buf )
342
- {
343
- long ret ;
344
- char * new_path ;
345
- if (current -> hp_node <= 0 ) {
346
- return original_sys_lstat64 (path , buf );
347
- }
348
-
349
- printk ("*** Lstat64ed file %s by %d on %ld %s: \n" , path , current -> pid ,
350
- current -> hp_node , current -> comm );
351
-
352
- new_path = replace_path_if_necessary (path );
353
- if (new_path == NULL ) {
354
- return original_sys_lstat64 (path , buf );
355
- }
356
- ret = original_sys_lstat64 (new_path , buf );
357
- printk ("*** replaced: %s\n" , new_path );
358
- printk ("*** return val: %ld\n" , ret );
359
- restore_path (path );
360
- return ret ;
361
- }
362
-
363
- asmlinkage long sys_stat_wrapper (char * path , struct __old_kernel_stat * buf )
364
- {
365
- long ret ;
366
- char * new_path ;
367
- if (current -> hp_node <= 0 ) {
368
- return original_sys_stat (path , buf );
369
- }
370
-
371
- printk ("*** Stated file %s by %d on %ld %s: \n" , path , current -> pid ,
372
- current -> hp_node , current -> comm );
373
-
374
- new_path = replace_path_if_necessary (path );
375
- if (new_path == NULL ) {
376
- return original_sys_stat (path , buf );
377
- }
378
- ret = original_sys_stat (new_path , buf );
379
- restore_path (path );
380
- return ret ;
381
- }
382
-
383
- asmlinkage long sys_stat64_wrapper (char * path , struct stat64 * buf )
384
- {
385
- long ret ;
386
- char * new_path ;
387
- if (current -> hp_node <= 0 ) {
388
- return original_sys_stat64 (path , buf );
389
- }
390
-
391
- printk ("*** Stat64ed file %s by %d on %ld %s: \n" , path , current -> pid ,
392
- current -> hp_node , current -> comm );
393
-
394
- new_path = replace_path_if_necessary (path );
395
- if (new_path == NULL ) {
396
- return original_sys_stat64 (path , buf );
397
- }
398
- ret = original_sys_stat64 (new_path , buf );
399
- restore_path (path );
400
- return ret ;
401
- }
402
-
403
213
/*
404
214
Create functions that replaces sys_call_table entries.
405
215
*/
0 commit comments