@@ -468,29 +468,62 @@ int VerifyInFstab(EvalContext *ctx, char *name, const Attributes *a, const Promi
468
468
mountpt = name ;
469
469
fstype = a -> mount .mount_type ;
470
470
471
+ char device [CF_BUFSIZE ];
472
+ if (StringEqual (fstype , "cifs" ) || StringEqual (fstype , "panfs" ))
473
+ {
474
+ NDEBUG_UNUSED int ret = snprintf (device , sizeof (device ), "%s%s" , host , rmountpt );
475
+ assert (ret >= 0 && ret < CF_BUFSIZE );
476
+ }
477
+ else
478
+ {
479
+ NDEBUG_UNUSED int ret = snprintf (device , sizeof (device ), "%s:%s" , host , rmountpt );
480
+ assert (ret >= 0 && ret < CF_BUFSIZE );
481
+ }
482
+
471
483
#if defined(__QNX__ ) || defined(__QNXNTO__ )
472
- snprintf (fstab , CF_BUFSIZE , "%s:%s \t %s %s\t%s 0 0" , host , rmountpt , mountpt , fstype , opts );
484
+ // QNX documents 4 fstab fields : https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.utilities/topic/f/fstab.html
485
+ // specialdevice mountpoint type mountoptions
486
+ // TODO Remove DUMP and PASS options used here (unsupported)?
487
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE , "%s \t %s %s\t%s 0 0" , device , mountpt , fstype , opts );
488
+ assert (ret >= 0 && ret < CF_BUFSIZE );
473
489
#elif defined(_CRAY )
474
490
char fstype_upper [CF_BUFSIZE ];
475
491
strlcpy (fstype_upper , fstype , CF_BUFSIZE );
476
492
ToUpperStrInplace (fstype_upper );
477
493
478
- snprintf (fstab , CF_BUFSIZE , "%s:%s \t %s %s\t%s" , host , rmountpt , mountpt , fstype_upper , opts );
494
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE , "%s \t %s %s\t%s" , device , mountpt , fstype_upper , opts );
495
+ assert (ret >= 0 && ret < CF_BUFSIZE );
479
496
break ;
480
497
#elif defined(__hpux )
481
- snprintf (fstab , CF_BUFSIZE , "%s:%s %s \t %s \t %s 0 0" , host , rmountpt , mountpt , fstype , opts );
498
+ // HP-UX documents 7 fstab fields: https://nixdoc.net/man-pages/HP-UX/man4/fstab.4.html
499
+ // deviceSpecialFile directory type options backupFrequency passNumber comment
500
+ // TODO Bring promise comment in as the 7th comment field # promise comment (stripped of newlines)
501
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE , "%s %s \t %s \t %s 0 0" , device , mountpt , fstype , opts );
502
+ assert (ret >= 0 && ret < CF_BUFSIZE );
482
503
#elif defined(_AIX )
483
- snprintf (fstab , CF_BUFSIZE ,
484
- "%s:\n\tdev\t= %s\n\ttype\t= %s\n\tvfs\t= %s\n\tnodename\t= %s\n\tmount\t= true\n\toptions\t= %s\n\taccount\t= false\n" ,
485
- mountpt , rmountpt , fstype , fstype , host , opts );
504
+ // AIX uses /etc/filesystems: https://www.ibm.com/docs/en/aix/7.2.0?topic=files-filesystems-file
505
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE ,
506
+ "%s:\n\tdev\t= %s\n\ttype\t= %s\n\tvfs\t= %s\n\tnodename\t= %s\n\tmount\t= true\n\toptions\t= %s\n\taccount\t= false\n" ,
507
+ mountpt , rmountpt , fstype , fstype , host , opts );
508
+ assert (ret >= 0 && ret < CF_BUFSIZE );
486
509
#elif defined(__linux__ )
487
- snprintf (fstab , CF_BUFSIZE , "%s:%s \t %s \t %s \t %s" , host , rmountpt , mountpt , fstype , opts );
510
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE , "%s \t %s \t %s \t %s" , device , mountpt , fstype , opts );
511
+ assert (ret >= 0 && ret < CF_BUFSIZE );
488
512
#elif defined(__NetBSD__ ) || defined(__OpenBSD__ ) || defined(__DragonFly__ ) || defined(__FreeBSD__ ) || defined(__APPLE__ )
489
- snprintf (fstab , CF_BUFSIZE , "%s:%s \t %s \t %s \t %s 0 0" , host , rmountpt , mountpt , fstype , opts );
513
+ // BSDs document 6 fstab fields https://man.freebsd.org/cgi/man.cgi?fstab(5)
514
+ // Device Mountpoint FStype Options Dump Pass
515
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE , "%s \t %s \t %s \t %s 0 0" , device , mountpt , fstype , opts );
516
+ assert (ret >= 0 && ret < CF_BUFSIZE );
490
517
#elif defined(__sun ) || defined(sco ) || defined(__SCO_DS )
491
- snprintf (fstab , CF_BUFSIZE , "%s:%s - %s %s - yes %s" , host , rmountpt , mountpt , fstype , opts );
518
+ // SunOS uses /etc/fstab and documents 7 fields: https://docs.oracle.com/cd/E19455-01/805-6331/fsadm-59727/index.html
519
+ // deviceToMount deviceToFsck mountPoint FStype fsckPass automount? mountOptions
520
+ // - is used for deviceToFsck for read-only and network based file systems
521
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE , "%s - %s %s - yes %s" , device , mountpt , fstype , opts );
522
+ assert (ret >= 0 && ret < CF_BUFSIZE );
492
523
#elif defined(__CYGWIN__ )
493
- snprintf (fstab , CF_BUFSIZE , "/bin/mount %s:%s %s" , host , rmountpt , mountpt );
524
+ // https://cygwin.com/cygwin-ug-net/using.html#mount-table
525
+ NDEBUG_UNUSED int ret = snprintf (fstab , CF_BUFSIZE , "/bin/mount %s %s" , device , mountpt );
526
+ assert (ret >= 0 && ret < CF_BUFSIZE );
494
527
#else
495
528
#error "Could not determine format of fstab entry on this platform."
496
529
#endif
@@ -503,7 +536,7 @@ int VerifyInFstab(EvalContext *ctx, char *name, const Attributes *a, const Promi
503
536
{
504
537
AppendItem (& FSTABLIST , fstab , NULL );
505
538
FSTAB_EDITS ++ ;
506
- cfPS (ctx , LOG_LEVEL_INFO , PROMISE_RESULT_CHANGE , pp , a , "Adding file system '%s:%s ' to '%s'" , host , rmountpt ,
539
+ cfPS (ctx , LOG_LEVEL_INFO , PROMISE_RESULT_CHANGE , pp , a , "Adding file system entry '%s' to '%s'" , fstab ,
507
540
VFSTAB [VSYSTEMHARDCLASS ]);
508
541
* result = PromiseResultUpdate (* result , PROMISE_RESULT_CHANGE );
509
542
changes += 1 ;
0 commit comments