Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/util-linux/volume_id/volume_id.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 45  Line 45 
45  #define ENABLE_FEATURE_VOLUMEID_UFS           0  #define ENABLE_FEATURE_VOLUMEID_UFS           0
46    
47    
48  typedef int (*raid_probe_fptr)(struct volume_id *id, uint64_t off, uint64_t size);  typedef int FAST_FUNC (*raid_probe_fptr)(struct volume_id *id, /*uint64_t off,*/ uint64_t size);
49  typedef int (*probe_fptr)(struct volume_id *id, uint64_t off);  typedef int FAST_FUNC (*probe_fptr)(struct volume_id *id /*, uint64_t off*/);
50    
51  static const raid_probe_fptr raid1[] = {  static const raid_probe_fptr raid1[] = {
52  #if ENABLE_FEATURE_VOLUMEID_LINUXRAID  #if ENABLE_FEATURE_VOLUMEID_LINUXRAID
# Line 109  static const probe_fptr fs2[] = { Line 109  static const probe_fptr fs2[] = {
109  #if ENABLE_FEATURE_VOLUMEID_EXT  #if ENABLE_FEATURE_VOLUMEID_EXT
110   volume_id_probe_ext,   volume_id_probe_ext,
111  #endif  #endif
112    #if ENABLE_FEATURE_VOLUMEID_BTRFS
113     volume_id_probe_btrfs,
114    #endif
115  #if ENABLE_FEATURE_VOLUMEID_REISERFS  #if ENABLE_FEATURE_VOLUMEID_REISERFS
116   volume_id_probe_reiserfs,   volume_id_probe_reiserfs,
117  #endif  #endif
# Line 150  static const probe_fptr fs2[] = { Line 153  static const probe_fptr fs2[] = {
153  #endif  #endif
154  };  };
155    
156  int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size)  int FAST_FUNC volume_id_probe_all(struct volume_id *id, /*uint64_t off,*/ uint64_t size)
157  {  {
158   unsigned i;   unsigned i;
159    
  if (id == NULL)  
  return -EINVAL;  
   
160   /* probe for raid first, cause fs probes may be successful on raid members */   /* probe for raid first, cause fs probes may be successful on raid members */
161   if (size) {   if (size) {
162   for (i = 0; i < ARRAY_SIZE(raid1); i++)   for (i = 0; i < ARRAY_SIZE(raid1); i++) {
163   if (raid1[i](id, off, size) == 0)   if (raid1[i](id, /*off,*/ size) == 0)
164   goto ret;   goto ret;
165     if (id->error)
166     goto ret;
167     }
168   }   }
169    
170   for (i = 0; i < ARRAY_SIZE(raid2); i++)   for (i = 0; i < ARRAY_SIZE(raid2); i++) {
171   if (raid2[i](id, off) == 0)   if (raid2[i](id /*,off*/) == 0)
172     goto ret;
173     if (id->error)
174   goto ret;   goto ret;
175     }
176    
177   /* signature in the first block, only small buffer needed */   /* signature in the first block, only small buffer needed */
178   for (i = 0; i < ARRAY_SIZE(fs1); i++)   for (i = 0; i < ARRAY_SIZE(fs1); i++) {
179   if (fs1[i](id, off) == 0)   if (fs1[i](id /*,off*/) == 0)
180     goto ret;
181     if (id->error)
182   goto ret;   goto ret;
183     }
184    
185   /* fill buffer with maximum */   /* fill buffer with maximum */
186   volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);   volume_id_get_buffer(id, 0, SB_BUFFER_SIZE);
187    
188   for (i = 0; i < ARRAY_SIZE(fs2); i++)   for (i = 0; i < ARRAY_SIZE(fs2); i++) {
189   if (fs2[i](id, off) == 0)   if (fs2[i](id /*,off*/) == 0)
190   goto ret;   goto ret;
191   return -1;   if (id->error)
192     goto ret;
193     }
194    
195   ret:   ret:
  /* If the filestystem in recognized, we free the allocated buffers,  
    otherwise they will stay in place for the possible next probe call */  
196   volume_id_free_buffer(id);   volume_id_free_buffer(id);
197     return (- id->error); /* 0 or -1 */
198    
  return 0;  
199  }  }
200    
201  /* open volume by device node */  /* open volume by device node */
202  struct volume_id *volume_id_open_node(int fd)  struct volume_id* FAST_FUNC volume_id_open_node(int fd)
203  {  {
204   struct volume_id *id;   struct volume_id *id;
205    
# Line 203  struct volume_id *volume_id_open_node(in Line 212  struct volume_id *volume_id_open_node(in
212    
213  #ifdef UNUSED  #ifdef UNUSED
214  /* open volume by major/minor */  /* open volume by major/minor */
215  struct volume_id *volume_id_open_dev_t(dev_t devt)  struct volume_id* FAST_FUNC volume_id_open_dev_t(dev_t devt)
216  {  {
217   struct volume_id *id;   struct volume_id *id;
218   char *tmp_node[VOLUME_ID_PATH_MAX];   char *tmp_node[VOLUME_ID_PATH_MAX];
# Line 214  struct volume_id *volume_id_open_dev_t(d Line 223  struct volume_id *volume_id_open_dev_t(d
223   /* create temporary node to open block device */   /* create temporary node to open block device */
224   unlink(tmp_node);   unlink(tmp_node);
225   if (mknod(tmp_node, (S_IFBLK | 0600), devt) != 0)   if (mknod(tmp_node, (S_IFBLK | 0600), devt) != 0)
226   bb_perror_msg_and_die("cannot mknod(%s)", tmp_node);   bb_perror_msg_and_die("can't mknod(%s)", tmp_node);
227    
228   id = volume_id_open_node(tmp_node);   id = volume_id_open_node(tmp_node);
229   unlink(tmp_node);   unlink(tmp_node);
# Line 223  struct volume_id *volume_id_open_dev_t(d Line 232  struct volume_id *volume_id_open_dev_t(d
232  }  }
233  #endif  #endif
234    
235  void free_volume_id(struct volume_id *id)  void FAST_FUNC free_volume_id(struct volume_id *id)
236  {  {
237   if (id == NULL)   if (id == NULL)
238   return;   return;

Legend:
Removed from v.983  
changed lines
  Added in v.984